home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Programming Contest / MacHack Contest.sit / MacHack Contest / !Problems next >
MacBinary  |  1998-06-18  |  18.9 KB  |  [TEXT/R*ch]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Thu Jun 18 12:41:27 1998, modified Thu Jun 18 12:41:27 1998, creator BBEdit, type ASCII, 17567 bytes "!Problems" , at 0x451f 1454 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[R*ch]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 09 21 50 72 6f 62 6c | 65 6d 73 00 00 00 00 00 |..!Probl|ems.....|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 52 2a 63 | 68 01 00 00 00 00 00 00 |.TEXTR*c|h.......|
|00000050| 00 00 00 00 00 44 9f 00 | 00 05 ae b1 ae f3 b7 b1 |.....D..|........|
|00000060| ae f3 b7 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 c4 9d 00 00 |........|........|
|00000080| 50 72 6f 62 6c 65 6d 20 | 30 31 20 2d 20 4d 6f 64 |Problem |01 - Mod|
|00000090| 65 20 53 6f 72 74 0d 0d | 54 68 69 73 20 70 72 6f |e Sort..|This pro|
|000000a0| 62 6c 65 6d 20 69 73 20 | 74 6f 20 73 6f 72 74 20 |blem is |to sort |
|000000b0| 61 6e 20 69 6e 70 75 74 | 20 73 74 72 69 6e 67 20 |an input| string |
|000000c0| 6f 66 20 4e 20 63 68 61 | 72 61 63 74 65 72 73 2c |of N cha|racters,|
|000000d0| 20 4e 3c 31 30 30 30 30 | 30 30 2c 20 62 61 73 65 | N<10000|00, base|
|000000e0| 64 20 6f 6e 0d 74 68 65 | 20 6e 75 6d 62 65 72 20 |d on.the| number |
|000000f0| 6f 66 20 74 69 6d 65 73 | 20 61 20 63 68 61 72 61 |of times| a chara|
|00000100| 63 74 65 72 20 6f 63 63 | 75 72 73 20 69 6e 20 74 |cter occ|urs in t|
|00000110| 68 65 20 69 6e 70 75 74 | 2e 20 20 54 68 65 20 6d |he input|. The m|
|00000120| 6f 73 74 20 66 72 65 71 | 75 65 6e 74 6c 79 0d 6f |ost freq|uently.o|
|00000130| 63 63 75 72 72 69 6e 67 | 20 63 68 61 72 61 63 74 |ccurring| charact|
|00000140| 65 72 20 73 68 6f 75 6c | 64 20 62 65 20 73 6f 72 |er shoul|d be sor|
|00000150| 74 65 64 20 74 6f 20 74 | 68 65 20 66 72 6f 6e 74 |ted to t|he front|
|00000160| 20 6f 66 20 74 68 65 20 | 73 74 72 69 6e 67 2c 20 | of the |string, |
|00000170| 66 6f 6c 6c 6f 77 65 64 | 20 62 79 0d 74 68 65 20 |followed| by.the |
|00000180| 6e 65 78 74 20 6d 6f 73 | 74 20 66 72 65 71 75 65 |next mos|t freque|
|00000190| 6e 74 6c 79 20 6f 63 63 | 75 72 72 69 6e 67 20 63 |ntly occ|urring c|
|000001a0| 68 61 72 61 63 74 65 72 | 2c 20 65 74 63 2e 20 20 |haracter|, etc. |
|000001b0| 46 6f 72 20 63 68 61 72 | 61 63 74 65 72 73 20 6f |For char|acters o|
|000001c0| 63 63 75 72 72 69 6e 67 | 0d 74 68 65 20 73 61 6d |ccurring|.the sam|
|000001d0| 65 20 6e 75 6d 62 65 72 | 20 6f 66 20 74 69 6d 65 |e number| of time|
|000001e0| 73 2c 20 74 68 65 20 63 | 68 61 72 61 63 74 65 72 |s, the c|haracter|
|000001f0| 20 74 68 61 74 20 6f 63 | 63 75 72 73 20 66 69 72 | that oc|curs fir|
|00000200| 73 74 20 69 6e 20 74 68 | 65 20 69 6e 70 75 74 20 |st in th|e input |
|00000210| 73 68 6f 75 6c 64 0d 62 | 65 20 73 6f 72 74 65 64 |should.b|e sorted|
|00000220| 20 74 6f 20 74 68 65 20 | 66 72 6f 6e 74 2e 0d 0d | to the |front...|
|00000230| 48 65 61 64 65 72 20 73 | 70 65 63 69 66 69 63 61 |Header s|pecifica|
|00000240| 74 69 6f 6e 0d 0d 70 61 | 73 63 61 6c 20 4f 53 45 |tion..pa|scal OSE|
|00000250| 72 72 20 4d 6f 64 65 53 | 6f 72 74 28 20 63 6f 6e |rr ModeS|ort( con|
|00000260| 73 74 20 46 53 53 70 65 | 63 2a 20 69 6e 66 69 6c |st FSSpe|c* infil|
|00000270| 65 2c 20 63 6f 6e 73 74 | 20 46 53 53 70 65 63 2a |e, const| FSSpec*|
|00000280| 20 6f 75 74 66 69 6c 65 | 20 29 3b 0d 0d 49 6e 70 | outfile| );..Inp|
|00000290| 75 74 20 73 70 65 63 69 | 66 69 63 61 74 69 6f 6e |ut speci|fication|
|000002a0| 0d 0d 54 68 65 20 69 6e | 66 69 6c 65 20 69 6e 70 |..The in|file inp|
|000002b0| 75 74 20 66 69 6c 65 20 | 63 6f 6e 74 61 69 6e 73 |ut file |contains|
|000002c0| 20 74 68 65 20 63 68 61 | 72 61 63 74 65 72 73 2e | the cha|racters.|
|000002d0| 20 20 49 6e 70 75 74 20 | 63 68 61 72 61 63 74 65 | Input |characte|
|000002e0| 72 73 20 6f 74 68 65 72 | 20 74 68 61 6e 0d 74 68 |rs other| than.th|
|000002f0| 6f 73 65 20 70 72 69 6e | 74 61 62 6c 65 20 6c 6f |ose prin|table lo|
|00000300| 77 20 61 73 63 69 69 20 | 63 68 61 72 61 63 74 65 |w ascii |characte|
|00000310| 72 73 20 63 2c 20 30 78 | 32 30 3c 63 3c 30 78 37 |rs c, 0x|20<c<0x7|
|00000320| 66 2c 20 6d 75 73 74 20 | 62 65 20 69 67 6e 6f 72 |f, must |be ignor|
|00000330| 65 64 2e 0d 0d 4f 75 74 | 70 75 74 20 73 70 65 63 |ed...Out|put spec|
|00000340| 69 66 69 63 61 74 69 6f | 6e 0d 0d 54 68 65 20 6f |ificatio|n..The o|
|00000350| 75 74 66 69 6c 65 20 6d | 75 73 74 20 62 65 20 63 |utfile m|ust be c|
|00000360| 72 65 61 74 65 64 20 61 | 6e 64 20 74 68 65 6e 20 |reated a|nd then |
|00000370| 66 69 6c 6c 65 64 20 77 | 69 74 68 20 74 68 65 20 |filled w|ith the |
|00000380| 73 6f 72 74 65 64 20 63 | 68 61 72 61 63 74 65 72 |sorted c|haracter|
|00000390| 73 2e 20 20 49 74 27 73 | 0d 66 69 6e 61 6c 20 6c |s. It's|.final l|
|000003a0| 65 6e 67 74 68 20 73 68 | 6f 75 6c 64 20 62 65 20 |ength sh|ould be |
|000003b0| 65 78 61 63 74 6c 79 20 | 74 68 65 20 73 61 6d 65 |exactly |the same|
|000003c0| 20 61 73 20 74 68 65 20 | 63 6f 75 6e 74 20 6f 66 | as the |count of|
|000003d0| 20 63 68 61 72 61 63 74 | 65 72 73 20 69 6e 20 74 | charact|ers in t|
|000003e0| 68 65 0d 61 6c 6c 6f 77 | 65 64 20 72 61 6e 67 65 |he.allow|ed range|
|000003f0| 20 28 30 78 32 30 3c 63 | 3c 30 78 37 66 29 20 28 | (0x20<c|<0x7f) (|
|00000400| 77 68 69 63 68 20 6d 61 | 79 20 62 65 20 73 68 6f |which ma|y be sho|
|00000410| 72 74 65 72 20 74 68 61 | 6e 20 74 68 65 20 69 6e |rter tha|n the in|
|00000420| 66 69 6c 65 20 66 69 6c | 65 20 6c 65 6e 67 74 68 |file fil|e length|
|00000430| 29 2e 0d 0d 53 61 6d 70 | 6c 65 20 69 6e 70 75 74 |)...Samp|le input|
|00000440| 0d 0d 61 62 63 64 65 66 | 67 68 61 62 62 63 63 63 |..abcdef|ghabbccc|
|00000450| 64 64 64 65 65 65 0d 6f | 72 0d 30 31 32 33 34 35 |dddeee.o|r.012345|
|00000460| 36 37 38 39 31 31 32 33 | 34 35 36 37 38 39 32 31 |67891123|45678921|
|00000470| 32 33 34 35 36 37 38 39 | 33 31 32 33 34 35 36 37 |23456789|31234567|
|00000480| 38 39 34 31 32 33 34 35 | 36 37 38 39 35 31 32 33 |89412345|67895123|
|00000490| 34 35 36 37 38 39 36 31 | 32 33 34 35 36 37 38 39 |45678961|23456789|
|000004a0| 37 31 32 33 34 35 36 37 | 38 39 31 0d 0d 53 61 6d |71234567|891..Sam|
|000004b0| 70 6c 65 20 6f 75 74 70 | 75 74 0d 0d 63 63 63 63 |ple outp|ut..cccc|
|000004c0| 64 64 64 64 65 65 65 65 | 62 62 62 61 61 66 67 68 |ddddeeee|bbbaafgh|
|000004d0| 0d 6f 72 0d 31 31 31 31 | 31 31 31 31 31 31 32 32 |.or.1111|11111122|
|000004e0| 32 32 32 32 32 32 32 33 | 33 33 33 33 33 33 33 33 |22222223|33333333|
|000004f0| 34 34 34 34 34 34 34 34 | 34 35 35 35 35 35 35 35 |44444444|45555555|
|00000500| 35 35 36 36 36 36 36 36 | 36 36 36 37 37 37 37 37 |55666666|66677777|
|00000510| 37 37 37 37 38 38 38 38 | 38 38 38 38 39 39 39 39 |77778888|88889999|
|00000520| 39 39 39 39 30 0d 0d 50 | 72 6f 62 6c 65 6d 20 30 |99990..P|roblem 0|
|00000530| 32 20 2d 20 48 6f 77 65 | 72 20 6f 66 20 54 61 6e |2 - Howe|r of Tan|
|00000540| 6f 69 0d 0d 54 68 69 73 | 20 70 72 6f 62 6c 65 6d |oi..This| problem|
|00000550| 20 69 73 20 74 6f 20 73 | 6f 6c 76 65 20 61 20 76 | is to s|olve a v|
|00000560| 61 72 69 61 6e 74 20 6f | 66 20 74 68 65 20 54 6f |ariant o|f the To|
|00000570| 77 65 72 20 6f 66 20 48 | 61 6e 6f 69 20 70 75 7a |wer of H|anoi puz|
|00000580| 7a 6c 65 2e 20 20 59 6f | 75 20 72 65 6d 65 6d 62 |zle. Yo|u rememb|
|00000590| 65 72 0d 74 68 65 20 54 | 6f 77 65 72 20 6f 66 20 |er.the T|ower of |
|000005a0| 48 61 6e 6f 69 2c 20 61 | 20 62 6f 61 72 64 20 77 |Hanoi, a| board w|
|000005b0| 69 74 68 20 74 68 72 65 | 65 20 70 65 67 73 2c 20 |ith thre|e pegs, |
|000005c0| 6f 6e 65 20 6f 66 20 77 | 68 69 63 68 20 68 61 73 |one of w|hich has|
|000005d0| 20 4e 20 64 69 73 6b 73 | 20 6f 66 20 73 69 7a 65 | N disks| of size|
|000005e0| 0d 31 2c 20 32 2c 20 33 | 2c 20 2e 2e 2e 20 4e 2c |.1, 2, 3|, ... N,|
|000005f0| 20 77 69 74 68 20 74 68 | 65 20 73 6d 61 6c 6c 65 | with th|e smalle|
|00000600| 73 74 20 64 69 73 6b 20 | 61 74 20 74 68 65 20 74 |st disk |at the t|
|00000610| 6f 70 2e 20 20 49 6e 20 | 74 68 65 20 73 74 61 6e |op. In |the stan|
|00000620| 64 61 72 64 20 70 75 7a | 7a 6c 65 2c 20 74 68 65 |dard puz|zle, the|
|00000630| 0d 67 6f 61 6c 20 69 73 | 20 74 6f 20 6d 6f 76 65 |.goal is| to move|
|00000640| 20 61 6c 6c 20 6f 66 20 | 74 68 65 20 64 69 73 6b | all of |the disk|
|00000650| 73 20 66 72 6f 6d 20 6f | 6e 65 20 70 65 67 20 74 |s from o|ne peg t|
|00000660| 6f 20 61 6e 6f 74 68 65 | 72 20 70 65 67 2c 20 62 |o anothe|r peg, b|
|00000670| 79 20 72 65 70 65 61 74 | 65 64 6c 79 0d 6d 6f 76 |y repeat|edly.mov|
|00000680| 69 6e 67 20 61 20 64 69 | 73 6b 20 66 72 6f 6d 20 |ing a di|sk from |
|00000690| 74 68 65 20 74 6f 70 20 | 6f 66 20 6f 6e 65 20 70 |the top |of one p|
|000006a0| 65 67 20 74 6f 20 61 6e | 6f 74 68 65 72 20 70 65 |eg to an|other pe|
|000006b0| 67 20 77 69 74 68 6f 75 | 74 20 65 76 65 72 20 70 |g withou|t ever p|
|000006c0| 6c 61 63 69 6e 67 20 61 | 0d 6c 61 72 67 65 72 20 |lacing a|.larger |
|000006d0| 64 69 73 6b 20 6f 6e 20 | 74 6f 70 20 6f 66 20 61 |disk on |top of a|
|000006e0| 20 73 6d 61 6c 6c 65 72 | 20 64 69 73 6b 2e 0d 0d | smaller| disk...|
|000006f0| 49 6e 20 6f 75 72 20 48 | 6f 77 65 72 20 6f 66 20 |In our H|ower of |
|00000700| 54 61 6e 6f 69 20 70 72 | 6f 62 6c 65 6d 2c 20 74 |Tanoi pr|oblem, t|
|00000710| 68 65 20 6f 62 6a 65 63 | 74 69 76 65 20 61 6e 64 |he objec|tive and|
|00000720| 20 74 68 65 20 63 6f 6e | 73 74 72 61 69 6e 74 73 | the con|straints|
|00000730| 20 61 72 65 20 74 68 65 | 20 73 61 6d 65 2c 0d 65 | are the| same,.e|
|00000740| 78 63 65 70 74 20 74 68 | 61 74 20 74 68 65 20 64 |xcept th|at the d|
|00000750| 69 73 6b 73 20 6f 6e 20 | 74 68 65 20 66 69 72 73 |isks on |the firs|
|00000760| 74 20 70 65 67 20 61 72 | 65 20 69 6e 69 74 69 61 |t peg ar|e initia|
|00000770| 6c 6c 79 20 69 6e 20 72 | 61 6e 64 6f 6d 20 6f 72 |lly in r|andom or|
|00000780| 64 65 72 2e 20 59 6f 75 | 20 63 61 6e 0d 73 74 69 |der. You| can.sti|
|00000790| 6c 6c 20 6f 6e 6c 79 20 | 6d 6f 76 65 20 61 20 73 |ll only |move a s|
|000007a0| 6d 61 6c 6c 65 72 20 64 | 69 73 6b 20 6f 6e 74 6f |maller d|isk onto|
|000007b0| 20 61 20 6c 61 72 67 65 | 72 20 64 69 73 6b 2e 0d | a large|r disk..|
|000007c0| 0d 59 6f 75 72 20 6f 62 | 6a 65 63 74 69 76 65 20 |.Your ob|jective |
|000007d0| 69 73 20 6f 75 74 70 75 | 74 20 74 68 65 20 6d 6f |is outpu|t the mo|
|000007e0| 76 65 73 20 72 65 71 75 | 69 72 65 64 20 74 6f 20 |ves requ|ired to |
|000007f0| 70 6c 61 63 65 20 61 6c | 6c 20 74 68 65 20 64 69 |place al|l the di|
|00000800| 73 6b 73 20 6f 6e 20 70 | 65 67 20 33 20 69 6e 0d |sks on p|eg 3 in.|
|00000810| 6f 72 64 65 72 20 77 69 | 74 68 20 74 68 65 20 73 |order wi|th the s|
|00000820| 6d 61 6c 6c 65 73 74 20 | 64 69 73 6b 20 61 74 20 |mallest |disk at |
|00000830| 74 68 65 20 74 6f 70 2e | 20 20 0d 0d 49 6e 70 75 |the top.| ..Inpu|
|00000840| 74 20 73 70 65 63 69 66 | 69 63 61 74 69 6f 6e 0d |t specif|ication.|
|00000850| 0d 54 68 65 20 66 69 72 | 73 74 20 6c 69 6e 65 20 |.The fir|st line |
|00000860| 6f 66 20 74 68 65 20 69 | 6e 70 75 74 20 66 69 6c |of the i|nput fil|
|00000870| 65 20 63 6f 6e 74 61 69 | 6e 73 20 61 6e 20 69 6e |e contai|ns an in|
|00000880| 74 65 67 65 72 20 4d 2c | 20 4d 3c 31 30 30 30 2c |teger M,| M<1000,|
|00000890| 20 74 68 65 20 6e 75 6d | 62 65 72 20 6f 66 0d 64 | the num|ber of.d|
|000008a0| 69 73 6b 73 20 69 6e 20 | 74 68 65 20 70 72 6f 62 |isks in |the prob|
|000008b0| 6c 65 6d 2e 20 20 54 68 | 65 20 6e 65 78 74 20 4d |lem. Th|e next M|
|000008c0| 20 6c 69 6e 65 73 20 63 | 6f 6e 74 61 69 6e 20 74 | lines c|ontain t|
|000008d0| 68 65 20 6e 75 6d 62 65 | 72 73 20 31 20 2e 2e 20 |he numbe|rs 1 .. |
|000008e0| 4d 2c 20 6f 6e 65 20 6e | 75 6d 62 65 72 0d 70 65 |M, one n|umber.pe|
|000008f0| 72 20 6c 69 6e 65 2c 20 | 72 61 6e 64 6f 6d 6c 79 |r line, |randomly|
|00000900| 20 6f 72 64 65 72 65 64 | 2c 20 77 68 65 72 65 20 | ordered|, where |
|00000910| 74 68 65 20 66 69 72 73 | 74 20 6e 75 6d 62 65 72 |the firs|t number|
|00000920| 20 69 73 20 74 68 65 20 | 73 69 7a 65 20 6f 66 20 | is the |size of |
|00000930| 74 68 65 20 74 6f 70 20 | 64 69 73 6b 0d 6f 6e 20 |the top |disk.on |
|00000940| 70 65 67 20 31 2c 20 74 | 68 65 20 73 65 63 6f 6e |peg 1, t|he secon|
|00000950| 64 20 6e 75 6d 62 65 72 | 20 69 73 20 74 68 65 20 |d number| is the |
|00000960| 73 69 7a 65 20 6f 66 20 | 74 68 65 20 32 6e 64 20 |size of |the 2nd |
|00000970| 64 69 73 6b 20 66 72 6f | 6d 20 74 68 65 20 74 6f |disk fro|m the to|
|00000980| 70 2c 20 65 74 63 2e 0d | 0d 4f 75 74 70 75 74 20 |p, etc..|.Output |
|00000990| 73 70 65 63 69 66 69 63 | 61 74 69 6f 6e 0d 0d 54 |specific|ation..T|
|000009a0| 68 65 20 6f 75 74 70 75 | 74 20 69 73 20 61 20 73 |he outpu|t is a s|
|000009b0| 65 71 75 65 6e 63 65 20 | 6f 66 20 6c 69 6e 65 73 |equence |of lines|
|000009c0| 2c 20 65 61 63 68 20 72 | 65 70 72 65 73 65 6e 74 |, each r|epresent|
|000009d0| 69 6e 67 20 61 20 73 69 | 6e 67 6c 65 20 6d 6f 76 |ing a si|ngle mov|
|000009e0| 65 2c 20 20 63 6f 6e 73 | 69 73 74 69 6e 67 0d 6f |e, cons|isting.o|
|000009f0| 66 20 74 68 65 20 73 6f | 75 72 63 65 20 70 65 67 |f the so|urce peg|
|00000a00| 20 6e 75 6d 62 65 72 20 | 66 6f 6c 6c 6f 77 65 64 | number |followed|
|00000a10| 20 62 79 20 61 20 63 6f | 6d 6d 61 20 28 27 2c 27 | by a co|mma (','|
|00000a20| 29 20 66 6f 6c 6c 6f 77 | 65 64 20 62 79 20 74 68 |) follow|ed by th|
|00000a30| 65 20 64 65 73 74 69 6e | 61 74 69 6f 6e 0d 70 65 |e destin|ation.pe|
|00000a40| 67 20 6e 75 6d 62 65 72 | 2c 20 66 6f 6c 6c 6f 77 |g number|, follow|
|00000a50| 65 64 20 62 79 20 61 20 | 72 65 74 75 72 6e 20 63 |ed by a |return c|
|00000a60| 68 61 72 61 63 74 65 72 | 2e 0d 0d 53 61 6d 70 6c |haracter|...Sampl|
|00000a70| 65 20 69 6e 70 75 74 0d | 0d 32 0d 32 0d 31 0d 0d |e input.|.2.2.1..|
|00000a80| 53 61 6d 70 6c 65 20 6f | 75 74 70 75 74 0d 0d 31 |Sample o|utput..1|
|00000a90| 2c 33 0d 31 2c 33 0d 0d | 50 72 6f 62 6c 65 6d 20 |,3.1,3..|Problem |
|00000aa0| 30 33 20 2d 20 50 65 72 | 69 6d 65 74 65 72 0d 0d |03 - Per|imeter..|
|00000ab0| 59 6f 75 20 61 72 65 20 | 69 6e 20 63 68 61 72 67 |You are |in charg|
|00000ac0| 65 20 6f 66 20 70 72 6f | 74 65 63 74 69 6e 67 20 |e of pro|tecting |
|00000ad0| 61 20 73 65 74 20 6f 66 | 20 64 65 66 65 6e 73 65 |a set of| defense|
|00000ae0| 6c 65 73 73 20 68 6f 6d | 65 6f 77 6e 65 72 73 20 |less hom|eowners |
|00000af0| 66 72 6f 6d 20 70 72 65 | 64 61 74 6f 72 73 0d 74 |from pre|dators.t|
|00000b00| 68 61 74 20 72 6f 61 6d | 20 74 68 65 20 61 72 65 |hat roam| the are|
|00000b10| 61 20 62 79 20 63 6f 6e | 73 74 72 75 63 74 69 6e |a by con|structin|
|00000b20| 67 20 61 20 73 69 6e 67 | 6c 65 20 66 65 6e 63 65 |g a sing|le fence|
|00000b30| 20 6f 66 20 6d 69 6e 69 | 6d 75 6d 20 6c 65 6e 67 | of mini|mum leng|
|00000b40| 74 68 20 74 68 61 74 0d | 65 6e 63 6c 6f 73 65 73 |th that.|encloses|
|00000b50| 20 61 6c 6c 20 6f 66 20 | 74 68 65 20 68 6f 6d 65 | all of |the home|
|00000b60| 73 2e 20 20 0d 0d 54 68 | 65 20 70 72 6f 74 6f 74 |s. ..Th|e protot|
|00000b70| 79 70 65 20 66 6f 72 20 | 79 6f 75 72 20 73 6f 6c |ype for |your sol|
|00000b80| 75 74 69 6f 6e 20 69 73 | 20 61 73 20 66 6f 6c 6c |ution is| as foll|
|00000b90| 6f 77 73 3a 0d 0d 74 79 | 70 65 64 65 66 20 73 74 |ows:..ty|pedef st|
|00000ba0| 72 75 63 74 20 4e 6f 64 | 65 20 7b 0d 09 6c 6f 6e |ruct Nod|e {..lon|
|00000bb0| 67 20 78 43 6f 6f 72 64 | 3b 0d 09 6c 6f 6e 67 20 |g xCoord|;..long |
|00000bc0| 79 43 6f 6f 72 64 3b 0d | 7d 20 4e 6f 64 65 3b 0d |yCoord;.|} Node;.|
|00000bd0| 0d 76 6f 69 64 20 50 65 | 72 69 6d 69 74 65 72 28 |.void Pe|rimiter(|
|00000be0| 0d 09 6c 6f 6e 67 20 6e | 75 6d 48 6f 6d 65 73 2c |..long n|umHomes,|
|00000bf0| 0d 09 4e 6f 64 65 20 68 | 6f 6d 65 73 54 6f 45 6e |..Node h|omesToEn|
|00000c00| 63 6c 6f 73 65 5b 5d 2c | 0d 09 6c 6f 6e 67 20 2a |close[],|..long *|
|00000c10| 6e 75 6d 4e 6f 64 65 73 | 49 6e 50 65 72 69 6d 69 |numNodes|InPerimi|
|00000c20| 74 65 72 2c 0d 09 6c 6f | 6e 67 20 6e 6f 64 65 73 |ter,..lo|ng nodes|
|00000c30| 49 6e 50 65 72 69 6d 69 | 74 65 72 5b 5d 0d 29 3b |InPerimi|ter[].);|
|00000c40| 0d 0d 59 6f 75 20 61 72 | 65 20 67 69 76 65 6e 20 |..You ar|e given |
|00000c50| 61 20 6c 69 73 74 20 68 | 6f 6d 65 73 54 6f 45 6e |a list h|omesToEn|
|00000c60| 63 6c 6f 73 65 20 6f 66 | 20 6e 75 6d 48 6f 6d 65 |close of| numHome|
|00000c70| 73 20 68 6f 6d 65 73 20 | 74 6f 20 70 72 6f 74 65 |s homes |to prote|
|00000c80| 63 74 20 20 28 6e 75 6d | 62 65 72 65 64 20 30 0d |ct (num|bered 0.|
|00000c90| 74 6f 20 6e 75 6d 48 6f | 6d 65 73 2d 31 29 20 62 |to numHo|mes-1) b|
|00000ca0| 79 20 63 6f 6e 73 74 72 | 75 63 74 69 6e 67 20 61 |y constr|ucting a|
|00000cb0| 20 66 65 6e 63 65 20 61 | 72 6f 75 6e 64 20 74 68 | fence a|round th|
|00000cc0| 65 20 68 6f 6d 65 73 2e | 20 59 6f 75 20 73 68 6f |e homes.| You sho|
|00000cd0| 75 6c 64 20 72 65 74 75 | 72 6e 20 61 0d 6c 69 73 |uld retu|rn a.lis|
|00000ce0| 74 20 6e 6f 64 65 73 49 | 6e 50 65 72 69 6d 69 74 |t nodesI|nPerimit|
|00000cf0| 65 72 20 6f 66 20 74 68 | 65 20 6e 75 6d 4e 6f 64 |er of th|e numNod|
|00000d00| 65 73 49 6e 50 65 72 69 | 6d 69 74 65 72 20 68 6f |esInPeri|miter ho|
|00000d10| 6d 65 73 20 74 6f 20 62 | 65 20 63 6f 6e 6e 65 63 |mes to b|e connec|
|00000d20| 74 65 64 20 62 79 20 61 | 0d 66 65 6e 63 65 2e 20 |ted by a|.fence. |
|00000d30| 20 54 68 65 20 66 65 6e | 63 65 20 6d 75 73 74 20 | The fen|ce must |
|00000d40| 65 6e 63 6c 6f 73 65 20 | 61 6c 6c 20 6f 66 20 74 |enclose |all of t|
|00000d50| 68 65 20 68 6f 6d 65 73 | 20 75 73 69 6e 67 20 74 |he homes| using t|
|00000d60| 68 65 20 6d 69 6e 69 6d | 75 6d 20 61 6d 6f 75 6e |he minim|um amoun|
|00000d70| 74 20 6f 66 0d 66 65 6e | 63 69 6e 67 20 6d 61 74 |t of.fen|cing mat|
|00000d80| 65 72 69 61 6c 2e 0d 0d | 0d 0d 50 72 6f 62 6c 65 |erial...|..Proble|
|00000d90| 6d 20 30 34 20 2d 20 54 | 65 78 74 20 50 72 6f 63 |m 04 - T|ext Proc|
|00000da0| 65 73 73 69 6e 67 0d 0d | 63 6f 6e 73 74 0d 09 6b |essing..|const..k|
|00000db0| 4d 61 78 48 61 6e 64 6c | 65 53 69 7a 65 20 3d 20 |MaxHandl|eSize = |
|00000dc0| 31 30 30 30 30 30 30 3b | 0d 63 6f 6e 73 74 0d 09 |1000000;|.const..|
|00000dd0| 6b 41 63 74 69 6f 6e 4d | 6f 76 65 20 3d 20 31 3b |kActionM|ove = 1;|
|00000de0| 0d 09 6b 41 63 74 69 6f | 6e 49 6e 73 65 72 74 20 |..kActio|nInsert |
|00000df0| 3d 20 32 3b 0d 09 6b 41 | 63 74 69 6f 6e 44 65 6c |= 2;..kA|ctionDel|
|00000e00| 65 74 65 20 3d 20 33 3b | 0d 09 6b 41 63 74 69 6f |ete = 3;|..kActio|
|00000e10| 6e 53 65 61 72 63 68 20 | 3d 20 34 3b 0d 09 6b 41 |nSearch |= 4;..kA|
|00000e20| 63 74 69 6f 6e 53 65 61 | 72 63 68 41 6e 64 52 65 |ctionSea|rchAndRe|
|00000e30| 70 6c 61 63 65 20 3d 20 | 35 3b 0d 63 6f 6e 73 74 |place = |5;.const|
|00000e40| 0d 09 6b 46 6c 61 67 43 | 61 73 65 53 65 6e 73 69 |..kFlagC|aseSensi|
|00000e50| 74 69 76 65 42 69 74 20 | 3d 20 30 3b 0d 09 6b 46 |tiveBit |= 0;..kF|
|00000e60| 6c 61 67 47 6c 6f 62 61 | 6c 42 69 74 20 3d 20 31 |lagGloba|lBit = 1|
|00000e70| 3b 0d 09 6b 46 6c 61 67 | 42 61 63 6b 77 61 72 64 |;..kFlag|Backward|
|00000e80| 73 42 69 74 20 3d 20 32 | 3b 0d 74 79 70 65 0d 20 |sBit = 2|;.type. |
|00000e90| 20 41 63 74 69 6f 6e 52 | 65 63 6f 72 64 20 3d 20 | ActionR|ecord = |
|00000ea0| 72 65 63 6f 72 64 0d 20 | 20 20 20 61 63 74 69 6f |record. | actio|
|00000eb0| 6e 3a 20 55 49 6e 74 33 | 32 3b 0d 20 20 20 20 61 |n: UInt3|2;. a|
|00000ec0| 6d 6f 75 6e 74 3a 20 53 | 49 6e 74 33 32 3b 0d 20 |mount: S|Int32;. |
|00000ed0| 20 20 20 66 6c 61 67 73 | 3a 20 55 49 6e 74 33 32 | flags|: UInt32|
|00000ee0| 3b 0d 20 20 20 20 73 65 | 61 72 63 68 3a 20 53 74 |;. se|arch: St|
|00000ef0| 72 32 35 35 3b 0d 20 20 | 20 20 72 65 70 6c 61 63 |r255;. | replac|
|00000f00| 65 3a 20 53 74 72 32 35 | 35 3b 0d 20 20 65 6e 64 |e: Str25|5;. end|
|00000f10| 3b 0d 20 20 41 63 74 69 | 6f 6e 52 65 63 6f 72 64 |;. Acti|onRecord|
|00000f20| 41 72 72 61 79 20 3d 20 | 61 72 72 61 79 5b 30 2e |Array = |array[0.|
|00000f30| 2e 30 5d 20 6f 66 20 41 | 63 74 69 6f 6e 52 65 63 |.0] of A|ctionRec|
|00000f40| 6f 72 64 3b 0d 20 20 41 | 63 74 69 6f 6e 52 65 63 |ord;. A|ctionRec|
|00000f50| 6f 72 64 41 72 72 61 79 | 50 74 72 20 3d 20 5e 41 |ordArray|Ptr = ^A|
|00000f60| 63 74 69 6f 6e 52 65 63 | 6f 72 64 41 72 72 61 79 |ctionRec|ordArray|
|00000f70| 3b 0d 0d 70 72 6f 63 65 | 64 75 72 65 20 54 65 78 |;..proce|dure Tex|
|00000f80| 74 50 72 6f 63 65 73 73 | 28 20 64 61 74 61 3a 20 |tProcess|( data: |
|00000f90| 48 61 6e 64 6c 65 3b 20 | 61 63 74 69 6f 6e 5f 63 |Handle; |action_c|
|00000fa0| 6f 75 6e 74 3a 20 55 49 | 6e 74 33 32 3b 20 61 63 |ount: UI|nt32; ac|
|00000fb0| 74 69 6f 6e 73 3a 0d 41 | 63 74 69 6f 6e 52 65 63 |tions:.A|ctionRec|
|00000fc0| 6f 72 64 41 72 72 61 79 | 50 74 72 20 29 3b 0d 0d |ordArray|Ptr );..|
|00000fd0| 47 69 76 65 6e 20 61 6e | 20 75 6e 6c 6f 63 6b 65 |Given an| unlocke|
|00000fe0| 64 20 68 61 6e 64 6c 65 | 20 74 6f 20 61 20 62 6c |d handle| to a bl|
|00000ff0| 6f 63 6b 20 6f 66 20 74 | 65 78 74 2c 20 79 6f 75 |ock of t|ext, you|
|00001000| 20 6e 65 65 64 20 74 6f | 20 61 70 70 6c 79 20 61 | need to| apply a|
|00001010| 20 73 65 71 75 65 6e 63 | 65 20 6f 66 0d 61 63 74 | sequenc|e of.act|
|00001020| 69 6f 6e 73 20 74 6f 20 | 74 68 65 20 64 61 74 61 |ions to |the data|
|00001030| 2e 20 20 59 6f 75 20 77 | 69 6c 6c 20 62 65 20 72 |. You w|ill be r|
|00001040| 65 71 75 69 72 65 64 20 | 74 6f 20 69 6e 73 65 72 |equired |to inser|
|00001050| 74 20 74 65 78 74 2c 20 | 64 65 6c 65 74 65 20 74 |t text, |delete t|
|00001060| 65 78 74 2c 20 73 65 61 | 72 63 68 0d 66 6f 72 20 |ext, sea|rch.for |
|00001070| 74 65 78 74 2c 20 73 65 | 61 72 63 68 20 66 6f 72 |text, se|arch for|
|00001080| 20 61 6e 64 20 72 65 70 | 6c 61 63 65 20 74 65 78 | and rep|lace tex|
|00001090| 74 2e 20 20 41 6c 6c 20 | 72 65 71 75 69 72 65 64 |t. All |required|
|000010a0| 20 61 63 74 69 6f 6e 73 | 20 74 61 6b 65 20 70 6c | actions| take pl|
|000010b0| 61 63 65 20 61 74 20 74 | 68 65 0d 70 6f 73 69 74 |ace at t|he.posit|
|000010c0| 69 6f 6e 20 6f 66 20 74 | 68 65 20 63 75 72 72 65 |ion of t|he curre|
|000010d0| 6e 74 20 73 65 6c 65 63 | 74 69 6f 6e 20 70 6f 69 |nt selec|tion poi|
|000010e0| 6e 74 65 72 2c 20 77 68 | 69 63 68 20 73 74 61 72 |nter, wh|ich star|
|000010f0| 74 73 20 61 74 20 7a 65 | 72 6f 2c 20 62 65 66 6f |ts at ze|ro, befo|
|00001100| 72 65 20 74 68 65 0d 66 | 69 72 73 74 20 63 68 61 |re the.f|irst cha|
|00001110| 72 61 63 74 65 72 20 69 | 6e 20 74 68 65 20 64 61 |racter i|n the da|
|00001120| 74 61 2e 20 20 49 6e 20 | 72 65 73 70 6f 6e 73 65 |ta. In |response|
|00001130| 20 74 6f 20 65 61 63 68 | 20 6f 66 20 74 68 65 20 | to each| of the |
|00001140| 61 63 74 69 6f 6e 20 63 | 6f 6d 6d 61 6e 64 73 20 |action c|ommands |
|00001150| 79 6f 75 0d 6e 65 65 64 | 20 74 6f 20 70 65 72 66 |you.need| to perf|
|00001160| 6f 72 6d 20 74 68 65 20 | 66 6f 6c 6c 6f 77 69 6e |orm the |followin|
|00001170| 67 3a 0d 0d 6b 41 63 74 | 69 6f 6e 4d 6f 76 65 20 |g:..kAct|ionMove |
|00001180| 2d 20 6d 6f 76 65 20 74 | 68 65 20 69 6e 74 65 72 |- move t|he inter|
|00001190| 6e 61 6c 20 70 6f 73 69 | 74 69 6f 6e 20 66 6f 72 |nal posi|tion for|
|000011a0| 77 61 72 64 20 62 79 20 | 74 68 65 20 61 6d 6f 75 |ward by |the amou|
|000011b0| 6e 74 20 66 69 65 6c 64 | 20 28 77 68 69 63 68 20 |nt field| (which |
|000011c0| 6d 61 79 0d 62 65 20 6e | 65 67 61 74 69 76 65 29 |may.be n|egative)|
|000011d0| 2e 20 20 28 45 78 61 6d | 70 6c 65 2c 20 6b 41 63 |. (Exam|ple, kAc|
|000011e0| 74 69 6f 6e 4d 6f 76 65 | 20 77 69 74 68 20 61 6d |tionMove| with am|
|000011f0| 6f 75 6e 74 20 73 65 74 | 20 74 6f 20 6b 4d 61 78 |ount set| to kMax|
|00001200| 48 61 6e 64 6c 65 53 69 | 7a 65 20 77 69 6c 6c 20 |HandleSi|ze will |
|00001210| 73 65 74 0d 74 68 65 20 | 69 6e 74 65 72 6e 61 6c |set.the |internal|
|00001220| 20 70 6f 69 6e 74 65 72 | 20 74 6f 20 62 65 20 47 | pointer| to be G|
|00001230| 65 74 48 61 6e 64 6c 65 | 53 69 7a 65 28 20 64 61 |etHandle|Size( da|
|00001240| 74 61 20 29 29 2e 0d 0d | 6b 41 63 74 69 6f 6e 49 |ta ))...|kActionI|
|00001250| 6e 73 65 72 74 20 2d 20 | 49 6e 73 65 72 74 20 74 |nsert - |Insert t|
|00001260| 68 65 20 72 65 70 6c 61 | 63 65 20 73 74 72 69 6e |he repla|ce strin|
|00001270| 67 20 61 74 20 74 68 65 | 20 63 75 72 72 65 6e 74 |g at the| current|
|00001280| 20 6c 6f 63 61 74 69 6f | 6e 2e 20 20 28 45 78 61 | locatio|n. (Exa|
|00001290| 6d 70 6c 65 2c 0d 69 66 | 20 74 68 65 20 69 6e 74 |mple,.if| the int|
|000012a0| 65 72 6e 61 6c 20 70 6f | 69 6e 74 65 72 20 69 73 |ernal po|inter is|
|000012b0| 20 47 65 74 48 61 6e 64 | 6c 65 53 69 7a 65 28 20 | GetHand|leSize( |
|000012c0| 64 61 74 61 20 29 2c 20 | 74 68 65 6e 20 74 68 65 |data ), |then the|
|000012d0| 20 72 65 70 6c 61 63 65 | 20 73 74 72 69 6e 67 20 | replace| string |
|000012e0| 77 69 6c 6c 0d 62 65 20 | 61 70 70 65 6e 64 65 64 |will.be |appended|
|000012f0| 20 74 6f 20 74 68 65 20 | 68 61 6e 64 6c 65 2e 0d | to the |handle..|
|00001300| 0d 6b 41 63 74 69 6f 6e | 44 65 6c 65 74 65 20 2d |.kAction|Delete -|
|00001310| 20 44 65 6c 65 74 65 20 | 74 68 65 20 6e 75 6d 62 | Delete |the numb|
|00001320| 65 72 20 6f 66 20 63 68 | 61 72 61 63 74 65 72 73 |er of ch|aracters|
|00001330| 20 73 70 65 63 69 66 69 | 65 64 20 62 79 20 74 68 | specifi|ed by th|
|00001340| 65 20 61 6d 6f 75 6e 74 | 20 66 69 65 6c 64 2e 20 |e amount| field. |
|00001350| 0d 54 68 65 20 69 6e 74 | 65 72 6e 61 6c 20 70 6f |.The int|ernal po|
|00001360| 73 69 74 69 6f 6e 20 70 | 6f 69 6e 74 65 72 20 69 |sition p|ointer i|
|00001370| 73 20 6e 65 76 65 72 20 | 6d 6f 76 65 64 2e 20 20 |s never |moved. |
|00001380| 49 66 20 74 68 65 20 61 | 6d 6f 75 6e 74 20 66 69 |If the a|mount fi|
|00001390| 65 6c 64 20 69 73 20 67 | 72 65 61 74 65 72 0d 74 |eld is g|reater.t|
|000013a0| 68 61 6e 20 74 68 65 20 | 6e 75 6d 62 65 72 20 6f |han the |number o|
|000013b0| 66 20 63 68 61 72 61 63 | 74 65 72 73 20 61 66 74 |f charac|ters aft|
|000013c0| 65 72 20 74 68 65 20 69 | 6e 74 65 72 6e 61 6c 20 |er the i|nternal |
|000013d0| 70 6f 69 6e 74 65 72 2c | 20 74 68 65 6e 20 66 65 |pointer,| then fe|
|000013e0| 77 65 72 20 63 68 61 72 | 61 63 74 65 72 73 0d 61 |wer char|acters.a|
|000013f0| 72 65 20 64 65 6c 65 74 | 65 64 20 73 75 63 68 20 |re delet|ed such |
|00001400| 74 68 61 74 20 74 68 65 | 20 68 61 6e 64 6c 65 20 |that the| handle |
|00001410| 69 73 20 74 72 75 6e 63 | 61 74 65 64 20 61 74 20 |is trunc|ated at |
|00001420| 74 68 65 20 63 75 72 72 | 65 6e 74 20 76 61 6c 75 |the curr|ent valu|
|00001430| 65 20 6f 66 20 74 68 65 | 0d 73 65 6c 65 63 74 69 |e of the|.selecti|
|00001440| 6f 6e 20 70 6f 69 6e 74 | 65 72 2e 0d 0d 6b 41 63 |on point|er...kAc|
|00001450| 74 69 6f 6e 53 65 61 72 | 63 68 20 2d 20 73 65 61 |tionSear|ch - sea|
|00001460| 72 63 68 20 66 6f 72 77 | 61 72 64 20 28 62 61 63 |rch forw|ard (bac|
|00001470| 6b 77 61 72 64 73 20 69 | 66 20 74 68 65 20 6b 46 |kwards i|f the kF|
|00001480| 6c 61 67 42 61 63 6b 77 | 61 72 64 73 42 69 74 20 |lagBackw|ardsBit |
|00001490| 69 73 20 73 65 74 20 69 | 6e 0d 74 68 65 20 66 6c |is set i|n.the fl|
|000014a0| 61 67 73 20 66 69 65 6c | 64 29 20 66 6f 72 20 74 |ags fiel|d) for t|
|000014b0| 68 65 20 73 65 61 72 63 | 68 20 66 69 65 6c 64 20 |he searc|h field |
|000014c0| 28 63 61 73 65 20 73 65 | 6e 73 69 74 69 76 65 6c |(case se|nsitivel|
|000014d0| 79 20 69 66 20 74 68 65 | 0d 6b 46 6c 61 67 43 61 |y if the|.kFlagCa|
|000014e0| 73 65 53 65 6e 73 74 69 | 74 69 76 65 42 69 74 20 |seSensti|tiveBit |
|000014f0| 69 73 20 73 65 74 20 69 | 6e 20 74 68 65 20 66 6c |is set i|n the fl|
|00001500| 61 67 73 20 66 69 65 6c | 64 29 2e 20 20 54 68 65 |ags fiel|d). The|
|00001510| 20 70 6f 73 69 74 69 6f | 6e 20 70 6f 69 6e 74 65 | positio|n pointe|
|00001520| 72 20 73 68 6f 75 6c 64 | 0d 62 65 20 73 65 74 20 |r should|.be set |
|00001530| 74 6f 20 70 6f 69 6e 74 | 20 62 65 66 6f 72 65 20 |to point| before |
|00001540| 74 68 65 20 66 69 72 73 | 74 20 63 68 61 72 61 63 |the firs|t charac|
|00001550| 74 65 72 20 6f 66 20 74 | 68 65 20 73 74 72 69 6e |ter of t|he strin|
|00001560| 67 20 69 66 20 69 74 20 | 69 73 20 66 6f 75 6e 64 |g if it |is found|
|00001570| 2c 20 6f 72 20 61 74 0d | 47 65 74 48 61 6e 64 6c |, or at.|GetHandl|
|00001580| 65 53 69 7a 65 20 28 7a | 65 72 6f 20 69 66 20 62 |eSize (z|ero if b|
|00001590| 61 63 6b 77 61 72 64 73 | 29 20 69 66 20 6e 6f 74 |ackwards|) if not|
|000015a0| 20 66 6f 75 6e 64 2e 20 | 20 49 66 20 74 68 65 72 | found. | If ther|
|000015b0| 65 20 69 73 20 61 20 6d | 61 74 63 68 20 61 74 20 |e is a m|atch at |
|000015c0| 74 68 65 0d 69 6e 69 74 | 69 61 6c 20 70 6f 73 69 |the.init|ial posi|
|000015d0| 74 69 6f 6e 2c 20 69 74 | 20 69 73 20 6e 6f 74 20 |tion, it| is not |
|000015e0| 63 6f 75 6e 74 65 64 20 | 28 69 65 2c 20 6b 41 63 |counted |(ie, kAc|
|000015f0| 74 69 6f 6e 4d 6f 76 65 | 20 2d 6b 4d 61 78 48 61 |tionMove| -kMaxHa|
|00001600| 6e 64 6c 65 53 69 7a 65 | 2c 20 6b 53 65 61 72 63 |ndleSize|, kSearc|
|00001610| 68 0d 27 68 65 6c 6c 6f | 27 2c 20 6b 53 65 61 72 |h.'hello|', kSear|
|00001620| 63 68 20 27 68 65 6c 6c | 6f 27 20 66 69 6e 64 73 |ch 'hell|o' finds|
|00001630| 20 74 68 65 20 73 65 63 | 6f 6e 64 20 6f 63 63 75 | the sec|ond occu|
|00001640| 72 61 6e 63 65 20 6f 66 | 20 27 68 65 6c 6c 6f 27 |rance of| 'hello'|
|00001650| 29 2e 0d 0d 6b 41 63 74 | 69 6f 6e 53 65 61 72 63 |)...kAct|ionSearc|
|00001660| 68 41 6e 64 52 65 70 6c | 61 63 65 20 2d 20 73 65 |hAndRepl|ace - se|
|00001670| 61 72 63 68 20 66 6f 72 | 77 61 72 64 20 28 6f 72 |arch for|ward (or|
|00001680| 20 62 61 63 6b 77 61 72 | 64 20 69 66 20 74 68 65 | backwar|d if the|
|00001690| 20 6b 46 6c 61 67 42 61 | 63 6b 77 61 72 64 73 42 | kFlagBa|ckwardsB|
|000016a0| 69 74 0d 69 73 20 73 65 | 74 20 69 6e 20 74 68 65 |it.is se|t in the|
|000016b0| 20 66 6c 61 67 73 20 66 | 69 65 6c 64 29 2c 20 62 | flags f|ield), b|
|000016c0| 75 74 20 77 68 65 6e 20 | 61 20 6d 61 74 63 68 20 |ut when |a match |
|000016d0| 69 73 20 66 6f 75 6e 64 | 2c 20 72 65 70 6c 61 63 |is found|, replac|
|000016e0| 65 20 69 74 20 77 69 74 | 68 20 74 68 65 0d 72 65 |e it wit|h the.re|
|000016f0| 70 6c 61 63 65 20 73 74 | 72 69 6e 67 2c 20 6c 65 |place st|ring, le|
|00001700| 61 76 69 6e 67 20 74 68 | 65 20 70 6f 73 69 74 69 |aving th|e positi|
|00001710| 6f 6e 20 70 6f 69 6e 74 | 65 72 20 75 6e 6d 6f 76 |on point|er unmov|
|00001720| 65 64 2e 20 20 49 66 20 | 74 68 65 20 6b 46 6c 61 |ed. If |the kFla|
|00001730| 67 47 6c 6f 62 61 6c 42 | 69 74 20 69 73 0d 73 65 |gGlobalB|it is.se|
|00001740| 74 20 69 6e 20 74 68 65 | 20 66 6c 61 67 73 20 66 |t in the| flags f|
|00001750| 69 65 6c 64 2c 20 63 6f | 6e 74 69 6e 75 65 20 73 |ield, co|ntinue s|
|00001760| 65 61 72 63 68 69 6e 67 | 20 61 73 20 6c 6f 6e 67 |earching| as long|
|00001770| 20 6d 61 74 63 68 65 73 | 20 63 6f 6e 74 69 6e 75 | matches| continu|
|00001780| 65 73 20 74 6f 20 62 65 | 0d 66 6f 75 6e 64 2e 20 |es to be|.found. |
|00001790| 20 52 65 70 65 61 74 65 | 64 20 73 65 61 72 63 68 | Repeate|d search|
|000017a0| 65 73 20 62 65 67 69 6e | 20 61 66 74 65 72 20 74 |es begin| after t|
|000017b0| 68 65 20 70 72 65 76 69 | 6f 75 73 20 72 65 70 6c |he previ|ous repl|
|000017c0| 61 63 65 20 73 74 72 69 | 6e 67 20 28 69 2e 65 2e |ace stri|ng (i.e.|
|000017d0| 2c 20 6e 65 76 65 72 0d | 72 65 70 6c 61 63 65 20 |, never.|replace |
|000017e0| 61 6e 79 20 63 68 61 72 | 61 63 74 65 72 73 20 6f |any char|acters o|
|000017f0| 66 20 74 68 65 20 72 65 | 70 6c 61 63 65 20 73 74 |f the re|place st|
|00001800| 72 69 6e 67 29 2e 20 20 | 46 6f 72 20 65 78 61 6d |ring). |For exam|
|00001810| 70 6c 65 2c 20 69 66 20 | 79 6f 75 20 72 65 70 6c |ple, if |you repl|
|00001820| 61 63 65 0d 27 61 61 61 | 27 20 77 69 74 68 20 27 |ace.'aaa|' with '|
|00001830| 41 42 41 27 20 28 63 61 | 73 65 20 69 6e 73 65 6e |ABA' (ca|se insen|
|00001840| 73 69 74 69 76 65 6c 79 | 29 20 69 6e 20 27 61 61 |sitively|) in 'aa|
|00001850| 61 61 61 61 61 61 27 20 | 79 6f 75 20 77 69 6c 6c |aaaaaa' |you will|
|00001860| 20 67 65 74 20 27 41 42 | 41 41 42 41 61 61 27 2c | get 'AB|AABAaa',|
|00001870| 0d 6e 6f 74 20 27 41 42 | 41 42 41 42 41 61 27 2e |.not 'AB|ABABAa'.|
|00001880| 20 20 52 65 70 6c 61 63 | 65 20 6e 65 76 65 72 20 | Replac|e never |
|00001890| 6d 6f 76 65 73 20 74 68 | 65 20 69 6e 74 65 72 6e |moves th|e intern|
|000018a0| 61 6c 20 70 6f 73 69 74 | 69 6f 6e 20 70 6f 69 6e |al posit|ion poin|
|000018b0| 74 65 72 2e 0d 0d 54 68 | 65 20 69 6e 74 65 72 6e |ter...Th|e intern|
|000018c0| 61 6c 20 73 65 6c 65 63 | 74 69 6f 6e 20 70 6f 69 |al selec|tion poi|
|000018d0| 6e 74 65 72 20 69 73 20 | 63 6f 6e 73 74 72 61 69 |nter is |constrai|
|000018e0| 6e 65 64 20 74 6f 20 62 | 65 20 69 6e 20 74 68 65 |ned to b|e in the|
|000018f0| 20 72 61 6e 67 65 20 6f | 66 20 30 20 61 6e 64 0d | range o|f 0 and.|
|00001900| 47 65 74 48 61 6e 64 6c | 65 53 69 7a 65 28 64 61 |GetHandl|eSize(da|
|00001910| 74 61 29 2c 20 69 6e 63 | 6c 75 73 69 76 65 2c 20 |ta), inc|lusive, |
|00001920| 61 74 20 61 6c 6c 20 74 | 69 6d 65 73 2e 20 20 53 |at all t|imes. S|
|00001930| 68 6f 75 6c 64 20 61 6e | 79 20 61 63 74 69 6f 6e |hould an|y action|
|00001940| 20 63 61 75 73 65 20 74 | 68 65 0d 73 65 6c 65 63 | cause t|he.selec|
|00001950| 74 69 6f 6e 20 70 6f 69 | 6e 74 65 72 20 74 6f 20 |tion poi|nter to |
|00001960| 62 65 63 6f 6d 65 20 6c | 65 73 73 20 74 68 61 6e |become l|ess than|
|00001970| 20 7a 65 72 6f 20 28 6f | 72 20 67 72 65 61 74 65 | zero (o|r greate|
|00001980| 72 20 74 68 61 6e 20 47 | 65 74 48 61 6e 64 6c 65 |r than G|etHandle|
|00001990| 53 69 7a 65 29 2c 0d 74 | 68 65 6e 20 79 6f 75 20 |Size),.t|hen you |
|000019a0| 6d 75 73 74 20 72 65 73 | 65 74 20 69 74 20 74 6f |must res|et it to|
|000019b0| 20 7a 65 72 6f 20 28 6f | 72 20 47 65 74 48 61 6e | zero (o|r GetHan|
|000019c0| 64 6c 65 53 69 7a 65 2c | 20 72 65 73 70 65 63 74 |dleSize,| respect|
|000019d0| 69 76 65 6c 79 29 2e 20 | 20 54 68 65 20 68 61 6e |ively). | The han|
|000019e0| 64 6c 65 0d 73 69 7a 65 | 20 77 69 6c 6c 20 6e 65 |dle.size| will ne|
|000019f0| 76 65 72 20 65 78 63 65 | 65 64 20 31 20 4d 65 67 |ver exce|ed 1 Meg|
|00001a00| 2c 20 61 6e 64 20 79 6f | 75 20 77 69 6c 6c 20 68 |, and yo|u will h|
|00001a10| 61 76 65 20 70 6c 65 6e | 74 79 20 6f 66 20 6d 65 |ave plen|ty of me|
|00001a20| 6d 6f 72 79 20 74 6f 20 | 70 6c 61 79 20 77 69 74 |mory to |play wit|
|00001a30| 68 2e 20 20 0d 0d 43 68 | 61 72 61 63 74 65 72 73 |h. ..Ch|aracters|
|00001a40| 20 66 72 6f 6d 20 63 68 | 72 28 31 32 37 29 2d 63 | from ch|r(127)-c|
|00001a50| 68 72 28 32 35 35 29 20 | 77 69 6c 6c 20 6e 65 76 |hr(255) |will nev|
|00001a60| 65 72 20 61 70 70 65 61 | 72 20 69 6e 20 74 68 65 |er appea|r in the|
|00001a70| 20 68 61 6e 64 6c 65 20 | 6f 72 20 61 6e 79 0d 73 | handle |or any.s|
|00001a80| 74 72 69 6e 67 73 2e 20 | 20 0d 0d 0d 0d 50 72 6f |trings. | ....Pro|
|00001a90| 62 6c 65 6d 20 30 35 20 | 2d 20 44 61 74 61 62 61 |blem 05 |- Databa|
|00001aa0| 73 65 0d 0d 74 79 70 65 | 0d 09 53 74 72 69 6e 67 |se..type|..String|
|00001ab0| 73 48 61 6e 64 6c 65 20 | 3d 20 48 61 6e 64 6c 65 |sHandle |= Handle|
|00001ac0| 3b 20 2f 2f 20 53 65 71 | 75 65 6e 63 65 20 6f 66 |; // Seq|uence of|
|00001ad0| 20 50 61 73 63 61 6c 20 | 53 74 72 69 6e 67 73 20 | Pascal |Strings |
|00001ae0| 70 61 63 6b 65 64 20 74 | 6f 67 65 74 68 65 72 0d |packed t|ogether.|
|00001af0| 09 44 61 74 61 62 61 73 | 65 48 61 6e 64 6c 65 20 |.Databas|eHandle |
|00001b00| 3d 20 48 61 6e 64 6c 65 | 3b 20 2f 2f 20 4d 75 73 |= Handle|; // Mus|
|00001b10| 74 20 62 65 20 61 20 72 | 65 61 6c 20 68 61 6e 64 |t be a r|eal hand|
|00001b20| 6c 65 0d 09 0d 70 72 6f | 63 65 64 75 72 65 20 44 |le...pro|cedure D|
|00001b30| 61 74 61 62 61 73 65 49 | 6e 69 74 28 20 76 61 72 |atabaseI|nit( var|
|00001b40| 20 64 61 74 61 62 61 73 | 65 3a 20 48 61 6e 64 6c | databas|e: Handl|
|00001b50| 65 3b 20 66 69 65 6c 64 | 5f 63 6f 75 6e 74 3a 20 |e; field|_count: |
|00001b60| 55 49 6e 74 33 32 20 29 | 3b 0d 70 72 6f 63 65 64 |UInt32 )|;.proced|
|00001b70| 75 72 65 20 44 61 74 61 | 62 61 73 65 41 64 64 45 |ure Data|baseAddE|
|00001b80| 6e 74 72 79 28 20 64 61 | 74 61 62 61 73 65 3a 20 |ntry( da|tabase: |
|00001b90| 48 61 6e 64 6c 65 3b 20 | 65 6e 74 72 79 3a 20 53 |Handle; |entry: S|
|00001ba0| 74 72 69 6e 67 73 48 61 | 6e 64 6c 65 20 29 3b 0d |tringsHa|ndle );.|
|00001bb0| 70 72 6f 63 65 64 75 72 | 65 20 44 61 74 61 62 61 |procedur|e Databa|
|00001bc0| 73 65 46 69 6e 64 45 6e | 74 72 79 28 20 64 61 74 |seFindEn|try( dat|
|00001bd0| 61 62 61 73 65 3a 20 48 | 61 6e 64 6c 65 3b 20 66 |abase: H|andle; f|
|00001be0| 69 65 6c 64 3a 20 55 49 | 6e 74 33 32 3b 20 63 6f |ield: UI|nt32; co|
|00001bf0| 6e 73 74 20 6d 61 74 63 | 68 3a 0d 53 74 72 32 35 |nst matc|h:.Str25|
|00001c00| 35 3b 20 76 61 72 20 65 | 6e 74 72 79 3a 20 53 74 |5; var e|ntry: St|
|00001c10| 72 69 6e 67 73 48 61 6e | 64 6c 65 20 29 3b 0d 70 |ringsHan|dle );.p|
|00001c20| 72 6f 63 65 64 75 72 65 | 20 44 61 74 61 62 61 73 |rocedure| Databas|
|00001c30| 65 44 65 6c 65 74 65 45 | 6e 74 72 79 28 20 64 61 |eDeleteE|ntry( da|
|00001c40| 74 61 62 61 73 65 3a 20 | 48 61 6e 64 6c 65 3b 20 |tabase: |Handle; |
|00001c50| 66 69 65 6c 64 3a 20 55 | 49 6e 74 33 32 3b 20 63 |field: U|Int32; c|
|00001c60| 6f 6e 73 74 20 6d 61 74 | 63 68 3a 0d 53 74 72 32 |onst mat|ch:.Str2|
|00001c70| 35 35 20 29 3b 0d 66 75 | 6e 63 74 69 6f 6e 20 44 |55 );.fu|nction D|
|00001c80| 61 74 61 62 61 73 65 43 | 6f 75 6e 74 28 20 64 61 |atabaseC|ount( da|
|00001c90| 74 61 62 61 73 65 3a 20 | 48 61 6e 64 6c 65 20 29 |tabase: |Handle )|
|00001ca0| 3a 20 55 49 6e 74 33 32 | 3b 0d 70 72 6f 63 65 64 |: UInt32|;.proced|
|00001cb0| 75 72 65 20 44 61 74 61 | 62 61 73 65 47 65 74 49 |ure Data|baseGetI|
|00001cc0| 6e 64 45 6e 74 72 79 28 | 20 64 61 74 61 62 61 73 |ndEntry(| databas|
|00001cd0| 65 3a 20 48 61 6e 64 6c | 65 3b 20 69 6e 64 65 78 |e: Handl|e; index|
|00001ce0| 3a 20 55 49 6e 74 33 32 | 3b 20 76 61 72 20 65 6e |: UInt32|; var en|
|00001cf0| 74 72 79 3a 0d 53 74 72 | 69 6e 67 73 48 61 6e 64 |try:.Str|ingsHand|
|00001d00| 6c 65 20 29 3b 0d 0d 59 | 6f 75 72 20 74 61 73 6b |le );..Y|our task|
|00001d10| 20 69 73 20 74 6f 20 77 | 72 69 74 65 20 61 20 73 | is to w|rite a s|
|00001d20| 65 74 20 6f 66 20 72 6f | 75 74 69 6e 65 73 20 74 |et of ro|utines t|
|00001d30| 6f 20 6d 61 69 6e 74 61 | 69 6e 20 61 20 64 61 74 |o mainta|in a dat|
|00001d40| 61 62 61 73 65 2e 0d 0d | 44 61 74 61 62 61 73 65 |abase...|Database|
|00001d50| 49 6e 69 74 20 63 72 65 | 61 74 65 73 20 61 20 6e |Init cre|ates a n|
|00001d60| 65 77 2c 20 65 6d 70 74 | 79 20 64 61 74 61 62 61 |ew, empt|y databa|
|00001d70| 73 65 20 72 65 61 64 79 | 20 74 6f 20 61 63 63 65 |se ready| to acce|
|00001d80| 70 74 20 72 65 63 6f 72 | 64 73 20 77 69 74 68 0d |pt recor|ds with.|
|00001d90| 66 69 65 6c 64 5f 63 6f | 75 6e 74 20 73 74 72 69 |field_co|unt stri|
|00001da0| 6e 67 20 66 69 65 6c 64 | 73 2e 20 20 54 68 65 20 |ng field|s. The |
|00001db0| 64 61 74 61 62 61 73 65 | 20 69 73 20 73 74 6f 72 |database| is stor|
|00001dc0| 65 64 20 69 6e 20 74 68 | 65 20 64 61 74 61 62 61 |ed in th|e databa|
|00001dd0| 73 65 20 48 61 6e 64 6c | 65 2e 0d 0d 44 61 74 61 |se Handl|e...Data|
|00001de0| 62 61 73 65 41 64 64 45 | 6e 74 72 79 20 61 64 64 |baseAddE|ntry add|
|00001df0| 73 20 61 6e 20 65 6e 74 | 72 79 20 28 77 68 69 63 |s an ent|ry (whic|
|00001e00| 68 20 69 73 20 61 20 48 | 61 6e 64 6c 65 20 74 6f |h is a H|andle to|
|00001e10| 20 66 69 65 6c 64 5f 63 | 6f 75 6e 74 20 70 61 73 | field_c|ount pas|
|00001e20| 63 61 6c 20 73 74 72 69 | 6e 67 73 0d 70 61 63 6b |cal stri|ngs.pack|
|00001e30| 65 64 20 74 6f 67 65 74 | 68 65 72 20 63 6f 6e 63 |ed toget|her conc|
|00001e40| 65 70 74 75 61 6c 6c 79 | 20 6e 75 6d 62 65 72 65 |eptually| numbere|
|00001e50| 64 20 31 20 74 6f 20 66 | 69 65 6c 64 5f 63 6f 75 |d 1 to f|ield_cou|
|00001e60| 6e 74 29 0d 0d 44 61 74 | 61 62 61 73 65 46 69 6e |nt)..Dat|abaseFin|
|00001e70| 64 45 6e 74 72 79 20 66 | 69 6e 64 73 20 61 6e 20 |dEntry f|inds an |
|00001e80| 65 6e 74 72 79 20 77 68 | 6f 73 65 20 66 69 65 6c |entry wh|ose fiel|
|00001e90| 64 20 28 62 65 74 77 65 | 65 6e 20 31 20 61 6e 64 |d (betwe|en 1 and|
|00001ea0| 20 66 69 65 6c 64 5f 63 | 6f 75 6e 74 29 20 73 74 | field_c|ount) st|
|00001eb0| 72 69 6e 67 0d 69 73 20 | 65 78 61 63 74 6c 79 20 |ring.is |exactly |
|00001ec0| 65 71 75 61 6c 20 74 6f | 20 6d 61 74 63 68 2e 20 |equal to| match. |
|00001ed0| 20 54 68 65 20 65 6e 74 | 72 79 20 69 73 20 72 65 | The ent|ry is re|
|00001ee0| 74 75 72 6e 65 64 20 69 | 6e 20 61 20 6e 65 77 6c |turned i|n a newl|
|00001ef0| 79 20 63 72 65 61 74 65 | 64 20 68 61 6e 64 6c 65 |y create|d handle|
|00001f00| 0d 28 77 68 69 63 68 20 | 77 69 6c 6c 20 62 65 20 |.(which |will be |
|00001f10| 64 69 73 70 6f 73 65 64 | 20 6f 66 20 75 73 69 6e |disposed| of usin|
|00001f20| 67 20 44 69 73 70 6f 73 | 65 48 61 6e 64 6c 65 29 |g Dispos|eHandle)|
|00001f30| 2e 20 20 52 65 74 75 72 | 6e 20 6e 69 6c 20 69 66 |. Retur|n nil if|
|00001f40| 20 6e 6f 20 6d 61 74 63 | 68 20 69 73 0d 66 6f 75 | no matc|h is.fou|
|00001f50| 6e 64 2e 20 20 49 66 20 | 6d 6f 72 65 20 74 68 61 |nd. If |more tha|
|00001f60| 6e 20 6f 6e 65 20 65 6e | 74 72 79 20 6d 61 74 63 |n one en|try matc|
|00001f70| 68 65 73 2c 20 79 6f 75 | 20 6d 75 73 74 20 72 65 |hes, you| must re|
|00001f80| 74 75 72 6e 20 74 68 65 | 20 65 61 72 6c 69 65 73 |turn the| earlies|
|00001f90| 74 20 61 64 64 65 64 0d | 65 6e 74 72 79 2e 0d 0d |t added.|entry...|
|00001fa0| 44 61 74 61 62 61 73 65 | 44 65 6c 65 74 65 45 6e |Database|DeleteEn|
|00001fb0| 74 72 79 20 66 69 6e 64 | 73 20 74 68 65 20 65 6e |try find|s the en|
|00001fc0| 74 72 79 20 74 68 61 74 | 20 44 61 74 61 62 61 73 |try that| Databas|
|00001fd0| 65 46 69 6e 64 45 6e 74 | 72 79 20 77 6f 75 6c 64 |eFindEnt|ry would|
|00001fe0| 20 66 69 6e 64 2c 20 61 | 6e 64 20 69 66 0d 66 6f | find, a|nd if.fo|
|00001ff0| 75 6e 64 20 72 65 6d 6f | 76 65 73 20 69 74 20 66 |und remo|ves it f|
|00002000| 72 6f 6d 20 74 68 65 20 | 64 61 74 61 62 61 73 65 |rom the |database|
|00002010| 2e 0d 0d 44 61 74 61 62 | 61 73 65 43 6f 75 6e 74 |...Datab|aseCount|
|00002020| 20 72 65 74 75 72 6e 73 | 20 74 68 65 20 6e 75 6d | returns| the num|
|00002030| 62 65 72 20 6f 66 20 65 | 6e 74 72 69 65 73 20 69 |ber of e|ntries i|
|00002040| 6e 20 74 68 65 20 64 61 | 74 61 62 61 73 65 2e 0d |n the da|tabase..|
|00002050| 0d 44 61 74 61 62 61 73 | 65 47 65 74 49 6e 64 45 |.Databas|eGetIndE|
|00002060| 6e 74 72 79 20 72 65 74 | 75 72 6e 73 20 74 68 65 |ntry ret|urns the|
|00002070| 20 65 6e 74 72 69 65 73 | 20 69 6e 20 74 68 65 20 | entries| in the |
|00002080| 44 61 74 61 62 61 73 65 | 20 69 6e 20 74 68 65 20 |Database| in the |
|00002090| 6f 72 64 65 72 20 74 68 | 65 79 20 77 65 72 65 0d |order th|ey were.|
|000020a0| 65 6e 74 65 72 65 64 2c | 20 31 20 66 6f 72 20 74 |entered,| 1 for t|
|000020b0| 68 65 20 65 61 72 6c 69 | 65 73 74 20 65 6e 74 65 |he earli|est ente|
|000020c0| 72 65 64 2c 20 44 61 74 | 61 62 61 73 65 43 6f 75 |red, Dat|abaseCou|
|000020d0| 6e 74 20 74 68 65 20 6c | 61 73 74 20 65 6e 74 65 |nt the l|ast ente|
|000020e0| 72 65 64 2e 0d 0d 41 6c | 6c 20 74 68 65 20 64 61 |red...Al|l the da|
|000020f0| 74 61 62 61 73 65 20 69 | 6e 66 6f 72 6d 61 74 69 |tabase i|nformati|
|00002100| 6f 6e 20 6d 75 73 74 20 | 62 65 20 73 74 6f 72 65 |on must |be store|
|00002110| 64 20 69 6e 20 74 68 65 | 20 72 65 61 6c 20 4d 61 |d in the| real Ma|
|00002120| 63 20 6d 65 6d 6f 72 79 | 20 6d 61 6e 61 67 65 72 |c memory| manager|
|00002130| 0d 68 61 6e 64 6c 65 20 | 2d 20 69 74 20 77 69 6c |.handle |- it wil|
|00002140| 6c 20 62 65 20 64 69 73 | 70 6f 73 65 64 20 77 69 |l be dis|posed wi|
|00002150| 74 68 20 44 69 73 70 6f | 73 65 48 61 6e 64 6c 65 |th Dispo|seHandle|
|00002160| 20 61 6e 64 20 74 68 61 | 74 20 6d 75 73 74 20 72 | and tha|t must r|
|00002170| 65 6c 65 61 73 65 20 61 | 6c 6c 0d 6d 65 6d 6f 72 |elease a|ll.memor|
|00002180| 79 2c 20 73 6f 20 64 6f | 20 6e 6f 74 20 73 74 6f |y, so do| not sto|
|00002190| 72 65 20 61 6e 79 20 65 | 78 74 72 61 20 69 6e 66 |re any e|xtra inf|
|000021a0| 6f 72 6d 61 74 69 6f 6e | 20 6f 75 74 73 69 64 65 |ormation| outside|
|000021b0| 20 74 68 65 20 68 61 6e | 64 6c 65 2e 20 20 41 6c | the han|dle. Al|
|000021c0| 73 6f 2c 20 79 6f 75 0d | 6d 75 73 74 20 62 65 20 |so, you.|must be |
|000021d0| 61 62 6c 65 20 74 6f 20 | 64 65 61 6c 20 77 69 74 |able to |deal wit|
|000021e0| 68 20 68 61 76 69 6e 67 | 20 6d 75 6c 74 69 70 6c |h having| multipl|
|000021f0| 65 20 64 61 74 61 62 61 | 73 65 73 20 69 6e 73 74 |e databa|ses inst|
|00002200| 61 6e 74 69 61 74 65 64 | 0d 73 69 6d 75 6c 74 61 |antiated|.simulta|
|00002210| 6e 65 6f 75 73 6c 79 2e | 0d 0d 59 6f 75 20 77 69 |neously.|..You wi|
|00002220| 6c 6c 20 6e 6f 74 20 62 | 65 20 67 69 76 65 6e 20 |ll not b|e given |
|00002230| 69 6e 76 61 6c 69 64 20 | 70 61 72 61 6d 65 74 65 |invalid |paramete|
|00002240| 72 73 20 73 6f 20 79 6f | 75 20 64 6f 6e 27 74 20 |rs so yo|u don't |
|00002250| 6e 65 65 64 20 74 6f 20 | 68 61 6e 64 6c 65 20 65 |need to |handle e|
|00002260| 72 72 6f 72 0d 63 68 65 | 63 6b 69 6e 67 2c 20 61 |rror.che|cking, a|
|00002270| 6e 64 20 74 68 65 72 65 | 20 77 69 6c 6c 20 62 65 |nd there| will be|
|00002280| 20 70 6c 65 6e 74 79 20 | 6f 66 20 6d 65 6d 6f 72 | plenty |of memor|
|00002290| 79 2e 0d 0d 41 6c 6c 20 | 73 74 72 69 6e 67 73 20 |y...All |strings |
|000022a0| 61 72 65 20 63 61 73 65 | 20 73 65 6e 73 69 74 69 |are case| sensiti|
|000022b0| 76 65 20 28 69 65 2c 20 | 74 72 65 61 74 65 64 20 |ve (ie, |treated |
|000022c0| 61 73 20 65 69 67 68 74 | 20 62 69 74 20 62 69 6e |as eight| bit bin|
|000022d0| 61 72 79 20 64 61 74 61 | 29 2e 0d 0d 0d 50 72 6f |ary data|)....Pro|
|000022e0| 62 6c 65 6d 20 30 36 20 | 2d 20 4c 65 67 61 6c 20 |blem 06 |- Legal |
|000022f0| 43 68 65 73 73 20 4d 6f | 76 65 73 0d 0d 44 65 65 |Chess Mo|ves..Dee|
|00002300| 70 20 54 68 6f 75 67 68 | 74 20 68 61 73 20 62 65 |p Though|t has be|
|00002310| 61 74 65 6e 20 6d 61 6e | 6b 69 6e 64 20 61 73 20 |aten man|kind as |
|00002320| 74 68 65 20 67 61 6d 65 | 20 6f 6e 63 65 20 74 68 |the game| once th|
|00002330| 6f 75 67 68 74 20 74 6f | 20 65 78 65 6d 70 6c 69 |ought to| exempli|
|00002340| 66 79 20 68 75 6d 61 6e | 0d 69 6e 74 75 69 74 69 |fy human|.intuiti|
|00002350| 6f 6e 2e 20 20 4f 75 72 | 20 4d 61 63 48 61 63 6b |on. Our| MacHack|
|00002360| 20 6c 61 62 6f 72 61 74 | 6f 72 79 20 69 73 20 73 | laborat|ory is s|
|00002370| 65 63 72 65 74 6c 79 20 | 63 6f 6e 73 74 72 75 63 |ecretly |construc|
|00002380| 74 69 6e 67 20 61 6e 20 | 69 6d 70 6c 61 6e 74 20 |ting an |implant |
|00002390| 74 68 61 74 0d 77 69 6c | 6c 20 6e 65 75 74 72 61 |that.wil|l neutra|
|000023a0| 6c 69 7a 65 20 74 68 65 | 20 63 61 6c 63 75 6c 61 |lize the| calcula|
|000023b0| 74 69 6f 6e 20 61 64 76 | 61 6e 74 61 67 65 20 68 |tion adv|antage h|
|000023c0| 65 6c 64 20 62 79 20 74 | 68 65 20 63 6f 6d 70 75 |eld by t|he compu|
|000023d0| 74 65 72 2c 20 61 6e 64 | 20 72 65 73 74 6f 72 65 |ter, and| restore|
|000023e0| 0d 6d 61 6e 6b 69 6e 64 | 20 74 6f 20 69 74 73 20 |.mankind| to its |
|000023f0| 72 69 67 68 74 66 75 6c | 20 70 6c 61 63 65 20 61 |rightful| place a|
|00002400| 73 20 74 68 65 20 63 68 | 61 6d 70 69 6f 6e 20 6f |s the ch|ampion o|
|00002410| 66 20 63 68 65 73 73 2c | 20 74 68 72 6f 75 67 68 |f chess,| through|
|00002420| 20 69 6e 74 75 69 74 69 | 6f 6e 20 61 6e 64 0d 63 | intuiti|on and.c|
|00002430| 75 6e 6e 69 6e 67 2e 20 | 20 59 6f 75 72 20 6a 6f |unning. | Your jo|
|00002440| 62 20 69 73 20 74 6f 20 | 77 72 69 74 65 20 74 68 |b is to |write th|
|00002450| 65 20 63 6f 64 65 20 74 | 68 61 74 20 77 69 6c 6c |e code t|hat will|
|00002460| 20 63 61 6c 63 75 6c 61 | 74 65 20 74 68 65 20 62 | calcula|te the b|
|00002470| 6f 61 72 64 20 70 6f 73 | 69 74 69 6f 6e 0d 72 65 |oard pos|ition.re|
|00002480| 73 75 6c 74 69 6e 67 20 | 66 72 6f 6d 20 61 20 73 |sulting |from a s|
|00002490| 65 71 75 65 6e 63 65 20 | 6f 66 20 6d 6f 76 65 73 |equence |of moves|
|000024a0| 2c 20 61 6c 6f 6e 67 20 | 77 69 74 68 20 74 68 65 |, along |with the|
|000024b0| 20 6c 65 67 61 6c 20 6d | 6f 76 65 73 20 61 76 61 | legal m|oves ava|
|000024c0| 69 6c 61 62 6c 65 20 74 | 6f 20 74 68 65 0d 6e 65 |ilable t|o the.ne|
|000024d0| 78 74 20 70 6c 61 79 65 | 72 2e 20 20 57 69 74 68 |xt playe|r. With|
|000024e0| 20 74 68 69 73 20 61 64 | 76 61 6e 74 61 67 65 2c | this ad|vantage,|
|000024f0| 20 74 68 65 20 68 75 6d | 61 6e 20 63 68 65 73 73 | the hum|an chess|
|00002500| 20 6d 61 73 74 65 72 20 | 77 69 6c 6c 20 62 65 20 | master |will be |
|00002510| 61 62 6c 65 20 74 6f 0d | 63 6f 6e 63 65 6e 74 72 |able to.|concentr|
|00002520| 61 74 65 20 6f 6e 20 73 | 74 72 61 74 65 67 79 2c |ate on s|trategy,|
|00002530| 20 72 61 74 68 65 72 20 | 74 68 61 6e 20 77 61 73 | rather |than was|
|00002540| 74 65 20 74 69 6d 65 20 | 63 61 6c 63 75 6c 61 74 |te time |calculat|
|00002550| 69 6e 67 20 6d 6f 76 65 | 73 2e 0d 0d 54 68 65 20 |ing move|s...The |
|00002560| 70 72 6f 74 6f 74 79 70 | 65 20 66 6f 72 20 79 6f |prototyp|e for yo|
|00002570| 75 72 20 73 6f 6c 75 74 | 69 6f 6e 20 69 73 20 61 |ur solut|ion is a|
|00002580| 73 20 66 6f 6c 6c 6f 77 | 73 3a 0d 0d 74 79 70 65 |s follow|s:..type|
|00002590| 64 65 66 20 65 6e 75 6d | 20 7b 6b 45 6d 70 74 79 |def enum| {kEmpty|
|000025a0| 3d 30 2c 6b 57 68 69 74 | 65 2c 6b 42 6c 61 63 6b |=0,kWhit|e,kBlack|
|000025b0| 7d 20 50 69 65 63 65 43 | 6f 6c 6f 72 3b 0d 74 79 |} PieceC|olor;.ty|
|000025c0| 70 65 64 65 66 20 65 6e | 75 6d 20 7b 6b 4e 6f 6e |pedef en|um {kNon|
|000025d0| 65 3d 30 2c 6b 50 61 77 | 6e 2c 6b 4b 6e 69 67 68 |e=0,kPaw|n,kKnigh|
|000025e0| 74 2c 6b 42 69 73 68 6f | 70 2c 6b 52 6f 6f 6b 2c |t,kBisho|p,kRook,|
|000025f0| 6b 51 75 65 65 6e 2c 6b | 4b 69 6e 67 7d 20 50 69 |kQueen,k|King} Pi|
|00002600| 65 63 65 52 61 6e 6b 3b | 0d 0d 74 79 70 65 64 65 |eceRank;|..typede|
|00002610| 66 20 73 74 72 75 63 74 | 20 53 71 75 61 72 65 20 |f struct| Square |
|00002620| 7b 0d 09 55 49 6e 74 31 | 36 20 72 6f 77 3b 09 2f |{..UInt1|6 row;./|
|00002630| 2f 20 30 2e 2e 37 2c 20 | 77 68 69 74 65 20 69 6e |/ 0..7, |white in|
|00002640| 69 74 69 61 6c 6c 79 20 | 6f 63 63 75 70 69 65 73 |itially |occupies|
|00002650| 20 72 6f 77 73 20 30 20 | 61 6e 64 20 31 2c 20 62 | rows 0 |and 1, b|
|00002660| 6c 61 63 6b 20 37 20 61 | 6e 64 20 36 0d 09 55 49 |lack 7 a|nd 6..UI|
|00002670| 6e 74 31 36 20 63 6f 6c | 3b 09 2f 2f 20 30 2e 2e |nt16 col|;.// 0..|
|00002680| 37 2c 20 77 68 69 74 65 | 20 6b 69 6e 67 20 73 74 |7, white| king st|
|00002690| 61 72 74 73 20 61 74 20 | 28 72 6f 77 2c 63 6f 6c |arts at |(row,col|
|000026a0| 29 20 3d 3d 20 28 30 2c | 34 29 0d 7d 20 53 71 75 |) == (0,|4).} Squ|
|000026b0| 61 72 65 3b 0d 0d 74 79 | 70 65 64 65 66 20 73 74 |are;..ty|pedef st|
|000026c0| 72 75 63 74 20 43 68 65 | 73 73 4d 6f 76 65 20 7b |ruct Che|ssMove {|
|000026d0| 0d 09 53 71 75 61 72 65 | 20 66 72 6f 6d 53 71 75 |..Square| fromSqu|
|000026e0| 61 72 65 3b 0d 09 53 71 | 75 61 72 65 20 74 6f 53 |are;..Sq|uare toS|
|000026f0| 71 75 61 72 65 3b 0d 09 | 42 6f 6f 6c 65 61 6e 20 |quare;..|Boolean |
|00002700| 63 61 70 74 75 72 65 3b | 0d 09 53 71 75 61 72 65 |capture;|..Square|
|00002710| 20 63 61 70 74 75 72 65 | 64 53 71 75 61 72 65 3b | capture|dSquare;|
|00002720| 09 2f 2f 20 76 61 6c 69 | 64 20 6f 6e 6c 79 20 69 |.// vali|d only i|
|00002730| 66 20 63 61 70 74 75 72 | 65 3d 3d 54 52 55 45 0d |f captur|e==TRUE.|
|00002740| 7d 20 43 68 65 73 73 4d | 6f 76 65 3b 0d 0d 74 79 |} ChessM|ove;..ty|
|00002750| 70 65 64 65 66 20 73 74 | 72 75 63 74 20 43 68 65 |pedef st|ruct Che|
|00002760| 73 73 50 69 65 63 65 20 | 7b 0d 09 50 69 65 63 65 |ssPiece |{..Piece|
|00002770| 43 6f 6c 6f 72 20 77 68 | 69 63 68 43 6f 6c 6f 72 |Color wh|ichColor|
|00002780| 3b 0d 09 50 69 65 63 65 | 52 61 6e 6b 20 77 68 69 |;..Piece|Rank whi|
|00002790| 63 68 52 61 6e 6b 3b 0d | 09 53 71 75 61 72 65 20 |chRank;.|.Square |
|000027a0| 70 69 65 63 65 4c 6f 63 | 61 74 69 6f 6e 3b 0d 7d |pieceLoc|ation;.}|
|000027b0| 20 43 68 65 73 73 50 69 | 65 63 65 3b 0d 0d 70 61 | ChessPi|ece;..pa|
|000027c0| 73 63 61 6c 20 76 6f 69 | 64 20 46 69 6e 64 4c 65 |scal voi|d FindLe|
|000027d0| 67 61 6c 43 68 65 73 73 | 4d 6f 76 65 73 28 0d 09 |galChess|Moves(..|
|000027e0| 55 49 6e 74 33 32 20 6e | 75 6d 50 72 69 6f 72 4d |UInt32 n|umPriorM|
|000027f0| 6f 76 65 73 2c 0d 09 43 | 68 65 73 73 4d 6f 76 65 |oves,..C|hessMove|
|00002800| 20 70 72 69 6f 72 4d 6f | 76 65 73 5b 5d 2c 0d 09 | priorMo|ves[],..|
|00002810| 55 49 6e 74 33 32 20 2a | 6e 75 6d 50 69 65 63 65 |UInt32 *|numPiece|
|00002820| 73 52 65 6d 61 69 6e 69 | 6e 67 2c 0d 09 43 68 65 |sRemaini|ng,..Che|
|00002830| 73 73 50 69 65 63 65 20 | 70 69 65 63 65 73 52 65 |ssPiece |piecesRe|
|00002840| 6d 61 69 6e 69 6e 67 5b | 5d 2c 0d 09 55 49 6e 74 |maining[|],..UInt|
|00002850| 33 32 20 2a 6e 75 6d 4c | 65 67 61 6c 4d 6f 76 65 |32 *numL|egalMove|
|00002860| 73 2c 0d 09 43 68 65 73 | 73 4d 6f 76 65 20 6c 65 |s,..Ches|sMove le|
|00002870| 67 61 6c 4d 6f 76 65 73 | 5b 5d 0d 29 3b 0d 0d 59 |galMoves|[].);..Y|
|00002880| 6f 75 72 20 46 69 6e 64 | 4c 65 67 61 6c 43 68 65 |our Find|LegalChe|
|00002890| 73 73 4d 6f 76 65 73 20 | 72 6f 75 74 69 6e 65 20 |ssMoves |routine |
|000028a0| 77 69 6c 6c 20 62 65 20 | 63 61 6c 6c 65 64 20 77 |will be |called w|
|000028b0| 69 74 68 20 61 20 6c 69 | 73 74 20 28 70 72 69 6f |ith a li|st (prio|
|000028c0| 72 4d 6f 76 65 73 29 20 | 6f 66 0d 6e 75 6d 50 72 |rMoves) |of.numPr|
|000028d0| 69 6f 72 4d 6f 76 65 73 | 20 74 68 61 74 20 68 61 |iorMoves| that ha|
|000028e0| 76 65 20 61 6c 72 65 61 | 64 79 20 74 61 6b 65 6e |ve alrea|dy taken|
|000028f0| 20 70 6c 61 63 65 20 66 | 72 6f 6d 20 74 68 65 20 | place f|rom the |
|00002900| 6e 6f 72 6d 61 6c 20 69 | 6e 69 74 69 61 6c 20 63 |normal i|nitial c|
|00002910| 68 65 73 73 62 6f 61 72 | 64 2e 0d 59 6f 75 20 73 |hessboar|d..You s|
|00002920| 68 6f 75 6c 64 20 6d 6f | 64 65 6c 20 74 68 65 20 |hould mo|del the |
|00002930| 65 66 66 65 63 74 73 20 | 6f 66 20 74 68 6f 73 65 |effects |of those|
|00002940| 20 6d 6f 76 65 73 20 61 | 6e 64 20 67 65 6e 65 72 | moves a|nd gener|
|00002950| 61 74 65 20 61 20 6c 69 | 73 74 0d 28 70 69 65 63 |ate a li|st.(piec|
|00002960| 65 73 52 65 6d 61 69 6e | 69 6e 67 29 20 6f 66 20 |esRemain|ing) of |
|00002970| 74 68 65 20 6e 75 6d 50 | 69 65 63 65 73 52 65 6d |the numP|iecesRem|
|00002980| 61 69 6e 69 6e 67 20 70 | 69 65 63 65 73 20 72 65 |aining p|ieces re|
|00002990| 6d 61 69 6e 69 6e 67 2c | 20 69 6e 63 6c 75 64 69 |maining,| includi|
|000029a0| 6e 67 20 74 68 65 69 72 | 0d 6c 6f 63 61 74 69 6f |ng their|.locatio|
|000029b0| 6e 20 6f 6e 20 74 68 65 | 20 62 6f 61 72 64 2c 20 |n on the| board, |
|000029c0| 61 6e 64 20 61 20 6c 69 | 73 74 20 28 6c 65 67 61 |and a li|st (lega|
|000029d0| 6c 4d 6f 76 65 73 29 20 | 6f 66 20 61 6c 6c 20 6e |lMoves) |of all n|
|000029e0| 75 6d 4c 65 67 61 6c 4d | 6f 76 65 73 20 6c 65 67 |umLegalM|oves leg|
|000029f0| 61 6c 20 6d 6f 76 65 73 | 0d 61 76 61 69 6c 61 62 |al moves|.availab|
|00002a00| 6c 65 20 74 6f 20 74 68 | 65 20 6e 65 78 74 20 70 |le to th|e next p|
|00002a10| 6c 61 79 65 72 2e 20 20 | 59 6f 75 20 73 68 6f 75 |layer. |You shou|
|00002a20| 6c 64 20 66 6f 6c 6c 6f | 77 20 61 6c 6c 20 72 75 |ld follo|w all ru|
|00002a30| 6c 65 73 20 6f 66 20 43 | 68 65 73 73 20 77 69 74 |les of C|hess wit|
|00002a40| 68 20 74 77 6f 0d 65 78 | 63 65 70 74 69 6f 6e 73 |h two.ex|ceptions|
|00002a50| 3a 20 73 74 61 6c 65 6d | 61 74 65 73 20 63 61 6e |: stalem|ates can|
|00002a60| 20 62 65 20 69 67 6e 6f | 72 65 64 2c 20 61 6e 64 | be igno|red, and|
|00002a70| 20 70 61 77 6e 73 20 61 | 6c 77 61 79 73 20 62 65 | pawns a|lways be|
|00002a80| 63 6f 6d 65 20 51 75 65 | 65 6e 73 20 77 68 65 6e |come Que|ens when|
|00002a90| 0d 70 72 6f 6d 6f 74 65 | 64 2e 20 20 52 65 6d 65 |.promote|d. Reme|
|00002aa0| 6d 62 65 72 20 74 6f 20 | 69 6e 63 6c 75 64 65 20 |mber to |include |
|00002ab0| 63 61 73 74 6c 69 6e 67 | 20 6d 6f 76 65 73 20 77 |castling| moves w|
|00002ac0| 68 65 6e 20 61 70 70 72 | 6f 70 72 69 61 74 65 20 |hen appr|opriate |
|00002ad0| 28 69 6e 64 69 63 61 74 | 65 64 20 62 79 0d 6d 6f |(indicat|ed by.mo|
|00002ae0| 76 69 6e 67 20 74 68 65 | 20 6b 69 6e 67 20 74 68 |ving the| king th|
|00002af0| 65 20 61 70 70 72 6f 70 | 72 69 61 74 65 20 74 77 |e approp|riate tw|
|00002b00| 6f 2f 74 68 72 65 65 20 | 73 71 75 61 72 65 73 29 |o/three |squares)|
|00002b10| 20 61 6e 64 20 65 6e 20 | 70 61 73 73 61 6e 74 20 | and en |passant |
|00002b20| 70 61 77 6e 0d 63 61 70 | 74 75 72 65 73 2e 0d 0d |pawn.cap|tures...|
|00002b30| 0d 50 72 6f 62 6c 65 6d | 20 30 37 20 2d 20 47 72 |.Problem| 07 - Gr|
|00002b40| 61 70 68 0d 0d 70 72 6f | 63 65 64 75 72 65 20 47 |aph..pro|cedure G|
|00002b50| 72 61 70 68 49 6e 69 74 | 28 20 76 61 72 20 67 72 |raphInit|( var gr|
|00002b60| 61 70 68 3a 20 48 61 6e | 64 6c 65 3b 20 76 65 72 |aph: Han|dle; ver|
|00002b70| 72 74 69 63 69 65 73 3a | 20 55 49 6e 74 33 32 20 |rticies:| UInt32 |
|00002b80| 29 3b 0d 70 72 6f 63 65 | 64 75 72 65 20 47 72 61 |);.proce|dure Gra|
|00002b90| 70 68 41 64 64 44 69 72 | 65 63 74 65 64 45 64 67 |phAddDir|ectedEdg|
|00002ba0| 65 28 20 67 72 61 70 68 | 3a 20 48 61 6e 64 6c 65 |e( graph|: Handle|
|00002bb0| 3b 20 76 65 72 74 65 78 | 31 2c 20 76 65 72 74 65 |; vertex|1, verte|
|00002bc0| 78 32 3a 20 55 49 6e 74 | 33 32 20 29 3b 0d 70 72 |x2: UInt|32 );.pr|
|00002bd0| 6f 63 65 64 75 72 65 20 | 47 72 61 70 68 46 69 6e |ocedure |GraphFin|
|00002be0| 64 52 6f 75 74 65 28 20 | 67 72 61 70 68 3a 20 48 |dRoute( |graph: H|
|00002bf0| 61 6e 64 6c 65 3b 20 76 | 65 72 74 65 78 31 2c 20 |andle; v|ertex1, |
|00002c00| 76 65 72 74 65 78 32 3a | 20 55 49 6e 74 33 32 3b |vertex2:| UInt32;|
|00002c10| 20 76 61 72 0d 76 65 72 | 74 69 63 69 65 73 3a 20 | var.ver|ticies: |
|00002c20| 48 61 6e 64 6c 65 20 29 | 3b 0d 0d 59 6f 75 72 20 |Handle )|;..Your |
|00002c30| 74 61 73 6b 20 69 73 20 | 74 6f 20 77 72 69 74 65 |task is |to write|
|00002c40| 20 61 20 73 65 74 20 6f | 66 20 72 6f 75 74 69 6e | a set o|f routin|
|00002c50| 65 73 20 74 6f 20 63 72 | 65 61 74 65 20 61 6e 64 |es to cr|eate and|
|00002c60| 20 74 72 61 76 65 72 73 | 65 20 61 20 64 69 72 65 | travers|e a dire|
|00002c70| 63 74 65 64 0d 67 72 61 | 70 68 2e 0d 0d 47 72 61 |cted.gra|ph...Gra|
|00002c80| 70 68 49 6e 69 74 20 63 | 72 65 61 74 65 73 20 61 |phInit c|reates a|
|00002c90| 20 6e 65 77 2c 20 65 6d | 70 74 79 20 64 69 72 65 | new, em|pty dire|
|00002ca0| 63 74 65 64 20 67 72 61 | 70 68 20 72 65 61 64 79 |cted gra|ph ready|
|00002cb0| 20 74 6f 20 61 63 63 65 | 70 74 20 64 69 72 65 63 | to acce|pt direc|
|00002cc0| 74 65 64 20 65 64 67 65 | 73 0d 77 69 74 68 20 76 |ted edge|s.with v|
|00002cd0| 65 72 72 74 69 63 69 65 | 73 20 76 65 72 74 69 63 |errticie|s vertic|
|00002ce0| 69 65 73 2e 20 20 0d 0d | 47 72 61 70 68 41 64 64 |ies. ..|GraphAdd|
|00002cf0| 44 69 72 65 63 74 65 64 | 45 64 67 65 20 61 64 64 |Directed|Edge add|
|00002d00| 73 20 61 20 64 69 72 65 | 63 74 65 64 20 65 64 67 |s a dire|cted edg|
|00002d10| 65 20 66 72 6f 6d 20 76 | 65 72 74 65 78 31 20 74 |e from v|ertex1 t|
|00002d20| 6f 20 76 65 72 74 65 78 | 32 0d 0d 47 72 61 70 68 |o vertex|2..Graph|
|00002d30| 46 69 6e 64 52 6f 75 74 | 65 20 66 69 6e 64 20 61 |FindRout|e find a|
|00002d40| 20 72 6f 75 74 65 20 66 | 72 6f 6d 20 76 65 72 74 | route f|rom vert|
|00002d50| 65 78 31 20 74 6f 20 76 | 65 72 74 65 78 32 2e 20 |ex1 to v|ertex2. |
|00002d60| 20 49 66 20 73 75 63 68 | 20 61 20 72 6f 75 74 65 | If such| a route|
|00002d70| 20 65 78 69 73 74 73 2c | 0d 74 68 65 6e 20 76 65 | exists,|.then ve|
|00002d80| 72 74 69 63 69 65 73 20 | 69 73 20 72 65 74 75 72 |rticies |is retur|
|00002d90| 6e 73 20 61 73 20 61 20 | 72 65 61 6c 20 4d 61 63 |ns as a |real Mac|
|00002da0| 20 68 61 6e 64 6c 65 20 | 74 6f 20 61 6e 20 61 72 | handle |to an ar|
|00002db0| 72 61 79 20 6f 66 20 55 | 49 6e 74 33 32 73 2c 20 |ray of U|Int32s, |
|00002dc0| 74 68 65 0d 66 69 72 73 | 74 20 69 73 20 76 65 72 |the.firs|t is ver|
|00002dd0| 74 65 78 31 2c 20 74 68 | 65 20 6c 61 73 74 20 69 |tex1, th|e last i|
|00002de0| 73 20 76 65 72 74 65 78 | 32 2e 20 20 45 61 63 68 |s vertex|2. Each|
|00002df0| 20 73 75 63 63 65 73 73 | 69 76 65 20 76 65 72 74 | success|ive vert|
|00002e00| 65 78 20 6d 75 73 74 20 | 68 61 76 65 0d 70 72 65 |ex must |have.pre|
|00002e10| 76 69 6f 75 73 6c 79 20 | 68 61 64 20 61 6e 20 65 |viously |had an e|
|00002e20| 64 67 65 20 61 64 64 65 | 64 20 77 69 74 68 20 47 |dge adde|d with G|
|00002e30| 72 61 70 68 41 64 64 44 | 69 72 65 63 74 65 64 45 |raphAddD|irectedE|
|00002e40| 64 67 65 2e 20 20 49 66 | 20 6e 6f 20 72 6f 75 74 |dge. If| no rout|
|00002e50| 65 20 65 78 69 73 74 73 | 2c 0d 72 65 74 75 72 6e |e exists|,.return|
|00002e60| 20 6e 69 6c 20 66 6f 72 | 20 76 65 72 74 69 63 69 | nil for| vertici|
|00002e70| 65 73 2e 20 20 4e 6f 20 | 76 65 72 74 65 78 20 73 |es. No |vertex s|
|00002e80| 68 6f 75 6c 64 20 61 70 | 70 65 61 72 20 6d 6f 72 |hould ap|pear mor|
|00002e90| 65 20 74 68 61 6e 20 6f | 6e 63 65 20 69 6e 20 74 |e than o|nce in t|
|00002ea0| 68 65 0d 76 65 72 74 69 | 63 69 65 73 20 68 61 6e |he.verti|cies han|
|00002eb0| 64 6c 65 2c 20 65 78 63 | 65 70 74 20 66 6f 72 20 |dle, exc|ept for |
|00002ec0| 74 68 65 20 63 61 73 65 | 20 77 68 65 72 65 20 76 |the case| where v|
|00002ed0| 65 72 74 65 78 31 20 69 | 73 20 74 68 65 20 73 61 |ertex1 i|s the sa|
|00002ee0| 6d 65 20 61 73 20 76 65 | 72 74 65 78 32 2c 20 69 |me as ve|rtex2, i|
|00002ef0| 6e 0d 77 68 69 63 68 20 | 63 61 73 65 20 79 6f 75 |n.which |case you|
|00002f00| 20 6d 75 73 74 20 66 69 | 6e 64 20 61 20 63 69 72 | must fi|nd a cir|
|00002f10| 63 75 6c 61 72 20 72 6f | 75 74 65 20 66 72 6f 6d |cular ro|ute from|
|00002f20| 20 76 65 72 74 65 78 31 | 20 62 61 63 6b 20 74 6f | vertex1| back to|
|00002f30| 20 69 74 73 65 6c 66 20 | 61 6e 64 20 73 6f 0d 76 | itself |and so.v|
|00002f40| 65 72 74 65 78 31 20 77 | 69 6c 6c 20 61 70 70 65 |ertex1 w|ill appe|
|00002f50| 61 72 20 65 78 61 63 74 | 6c 79 20 74 77 69 63 65 |ar exact|ly twice|
|00002f60| 2c 20 6f 6e 63 65 20 61 | 74 20 74 68 65 20 73 74 |, once a|t the st|
|00002f70| 61 72 74 20 61 6e 64 20 | 6f 6e 63 65 20 61 74 20 |art and |once at |
|00002f80| 74 68 65 20 65 6e 64 20 | 6f 66 20 74 68 65 0d 76 |the end |of the.v|
|00002f90| 65 72 74 69 63 69 65 73 | 20 68 61 6e 64 6c 65 2e |erticies| handle.|
|00002fa0| 0d 0d 41 6c 6c 20 74 68 | 65 20 67 72 61 70 68 20 |..All th|e graph |
|00002fb0| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 20 6d 75 73 74 |informat|ion must|
|00002fc0| 20 62 65 20 73 74 6f 72 | 65 64 20 69 6e 20 74 68 | be stor|ed in th|
|00002fd0| 65 20 72 65 61 6c 20 4d | 61 63 20 6d 65 6d 6f 72 |e real M|ac memor|
|00002fe0| 79 20 6d 61 6e 61 67 65 | 72 20 68 61 6e 64 6c 65 |y manage|r handle|
|00002ff0| 0d 2d 20 69 74 20 77 69 | 6c 6c 20 62 65 20 64 69 |.- it wi|ll be di|
|00003000| 73 70 6f 73 65 64 20 77 | 69 74 68 20 44 69 73 70 |sposed w|ith Disp|
|00003010| 6f 73 65 48 61 6e 64 6c | 65 20 61 6e 64 20 74 68 |oseHandl|e and th|
|00003020| 61 74 20 6d 75 73 74 20 | 72 65 6c 65 61 73 65 20 |at must |release |
|00003030| 61 6c 6c 20 6d 65 6d 6f | 72 79 2c 20 73 6f 0d 64 |all memo|ry, so.d|
|00003040| 6f 6e 74 20 73 74 6f 72 | 65 20 61 6e 79 20 65 78 |ont stor|e any ex|
|00003050| 74 72 61 20 69 6e 66 6f | 72 6d 61 74 69 6f 6e 20 |tra info|rmation |
|00003060| 6f 75 74 73 69 64 65 20 | 74 68 65 20 68 61 6e 64 |outside |the hand|
|00003070| 6c 65 2e 20 20 41 6c 73 | 6f 2c 20 79 6f 75 20 6d |le. Als|o, you m|
|00003080| 75 73 74 20 62 65 20 61 | 62 6c 65 20 74 6f 0d 64 |ust be a|ble to.d|
|00003090| 65 61 6c 20 77 69 74 68 | 20 68 61 76 69 6e 67 20 |eal with| having |
|000030a0| 6d 75 6c 74 69 70 6c 65 | 20 67 72 61 70 68 73 20 |multiple| graphs |
|000030b0| 69 6e 73 74 61 6e 74 69 | 61 74 65 64 20 73 69 6d |instanti|ated sim|
|000030c0| 75 6c 74 61 6e 65 6f 75 | 73 6c 79 2e 0d 0d 0d 50 |ultaneou|sly....P|
|000030d0| 72 6f 62 6c 65 6d 20 30 | 38 20 2d 20 50 61 63 6b |roblem 0|8 - Pack|
|000030e0| 69 6e 67 0d 0d 50 6f 69 | 6e 74 41 72 72 61 79 20 |ing..Poi|ntArray |
|000030f0| 3d 20 61 72 72 61 79 5b | 30 2e 2e 30 5d 20 6f 66 |= array[|0..0] of|
|00003100| 20 50 6f 69 6e 74 3b 0d | 50 6f 69 6e 74 41 72 72 | Point;.|PointArr|
|00003110| 61 79 50 74 72 20 3d 20 | 5e 50 6f 69 6e 74 41 72 |ayPtr = |^PointAr|
|00003120| 72 61 79 3b 0d 0d 70 72 | 6f 63 65 64 75 72 65 20 |ray;..pr|ocedure |
|00003130| 50 61 63 6b 42 6f 78 65 | 73 28 20 66 72 61 6d 65 |PackBoxe|s( frame|
|00003140| 3a 20 52 65 63 74 3b 20 | 62 6f 78 5f 63 6f 75 6e |: Rect; |box_coun|
|00003150| 74 3a 20 55 49 6e 74 33 | 32 3b 20 62 6f 78 65 73 |t: UInt3|2; boxes|
|00003160| 3a 20 50 6f 69 6e 74 41 | 72 72 61 79 3b 0d 74 6f |: PointA|rray;.to|
|00003170| 70 6c 65 66 74 73 3a 20 | 50 6f 69 6e 74 41 72 72 |plefts: |PointArr|
|00003180| 61 79 50 74 72 20 29 3b | 0d 0d 59 6f 75 72 20 74 |ayPtr );|..Your t|
|00003190| 61 73 6b 20 69 73 20 74 | 6f 20 70 61 63 6b 20 61 |ask is t|o pack a|
|000031a0| 20 73 65 74 20 6f 66 20 | 32 2d 64 69 6d 65 6e 73 | set of |2-dimens|
|000031b0| 69 6f 6e 61 6c 20 62 6f | 78 65 73 20 69 6e 74 6f |ional bo|xes into|
|000031c0| 20 61 20 67 69 76 65 6e | 20 66 72 61 6d 65 20 72 | a given| frame r|
|000031d0| 65 63 74 61 6e 67 6c 65 | 0d 73 75 63 68 20 74 68 |ectangle|.such th|
|000031e0| 61 74 20 74 68 65 20 69 | 6e 74 65 72 69 6f 72 20 |at the i|nterior |
|000031f0| 6f 66 20 74 68 65 20 62 | 6f 78 65 73 20 64 6f 20 |of the b|oxes do |
|00003200| 6e 6f 74 20 69 6e 74 65 | 72 73 65 63 74 2e 0d 0d |not inte|rsect...|
|00003210| 54 68 65 20 62 6f 78 20 | 64 69 6d 65 6e 73 69 6f |The box |dimensio|
|00003220| 6e 73 20 61 72 65 20 72 | 65 70 72 65 73 65 6e 74 |ns are r|epresent|
|00003230| 65 64 20 62 79 20 68 65 | 69 67 68 74 20 28 74 68 |ed by he|ight (th|
|00003240| 65 20 2e 76 20 63 6f 6d | 70 6f 6e 65 6e 74 29 20 |e .v com|ponent) |
|00003250| 61 6e 64 20 77 69 64 74 | 68 20 28 74 68 65 0d 2e |and widt|h (the..|
|00003260| 68 20 63 6f 6d 70 6f 6e | 65 6e 74 29 20 69 6e 20 |h compon|ent) in |
|00003270| 74 68 65 20 62 6f 78 65 | 73 20 61 72 72 61 79 2e |the boxe|s array.|
|00003280| 20 20 59 6f 75 20 6d 75 | 73 74 20 66 69 6e 64 20 | You mu|st find |
|00003290| 61 20 77 61 79 20 74 6f | 20 66 69 74 20 61 6c 6c |a way to| fit all|
|000032a0| 20 74 68 65 0d 72 65 63 | 74 61 6e 67 6c 65 73 20 | the.rec|tangles |
|000032b0| 69 6e 73 69 64 65 20 74 | 68 65 20 66 72 61 6d 65 |inside t|he frame|
|000032c0| 20 77 69 74 68 6f 75 74 | 20 6f 76 65 72 6c 61 70 | without| overlap|
|000032d0| 70 69 6e 67 2e 20 20 4a | 75 73 74 20 6c 69 6b 65 |ping. J|ust like|
|000032e0| 20 51 75 69 63 6b 44 72 | 61 77 20 73 74 61 6e 64 | QuickDr|aw stand|
|000032f0| 61 72 64 0d 72 65 63 74 | 61 6e 67 6c 65 73 2c 20 |ard.rect|angles, |
|00003300| 74 77 6f 20 61 64 6a 61 | 63 65 6e 74 20 72 65 63 |two adja|cent rec|
|00003310| 74 61 6e 67 6c 65 73 20 | 63 6f 75 6c 64 20 68 61 |tangles |could ha|
|00003320| 76 65 20 74 68 65 20 73 | 61 6d 65 20 72 69 67 68 |ve the s|ame righ|
|00003330| 74 2f 6c 65 66 74 20 63 | 6f 6f 72 64 69 6e 61 74 |t/left c|oordinat|
|00003340| 65 2c 0d 73 6f 20 74 68 | 61 74 20 74 68 65 79 20 |e,.so th|at they |
|00003350| 61 72 65 20 74 6f 75 63 | 68 69 6e 67 20 62 75 74 |are touc|hing but|
|00003360| 20 6e 6f 74 20 6f 76 65 | 72 6c 61 70 70 69 6e 67 | not ove|rlapping|
|00003370| 2e 20 20 53 69 6d 69 6c | 61 72 6c 79 2c 20 72 65 |. Simil|arly, re|
|00003380| 63 74 61 6e 67 6c 65 73 | 20 6d 61 79 20 74 6f 75 |ctangles| may tou|
|00003390| 63 68 0d 74 68 65 20 65 | 64 67 65 20 6f 66 20 74 |ch.the e|dge of t|
|000033a0| 68 65 20 66 72 61 6d 65 | 2e 20 20 57 68 65 6e 20 |he frame|. When |
|000033b0| 79 6f 75 20 66 69 6e 64 | 20 61 20 73 6f 6c 75 74 |you find| a solut|
|000033c0| 69 6f 6e 2c 20 79 6f 75 | 20 73 68 6f 75 6c 64 20 |ion, you| should |
|000033d0| 72 65 74 75 72 6e 20 74 | 68 65 20 74 6f 70 6c 65 |return t|he tople|
|000033e0| 66 74 0d 63 6f 6f 72 64 | 69 6e 61 74 65 73 20 6f |ft.coord|inates o|
|000033f0| 66 20 65 61 63 68 20 72 | 65 63 74 61 6e 67 65 2e |f each r|ectange.|
|00003400| 20 20 52 65 63 74 61 6e | 67 6c 65 73 20 6d 61 79 | Rectan|gles may|
|00003410| 20 6f 6e 6c 79 20 62 65 | 20 6d 6f 76 65 64 20 68 | only be| moved h|
|00003420| 6f 72 72 69 7a 6f 6e 74 | 61 6c 6c 79 20 6f 72 0d |orrizont|ally or.|
|00003430| 76 65 72 74 69 63 61 6c | 6c 79 2c 20 74 68 65 79 |vertical|ly, they|
|00003440| 20 6d 61 79 20 6e 6f 74 | 20 62 65 20 72 6f 74 61 | may not| be rota|
|00003450| 74 65 64 2e 0d 0d 45 78 | 61 6d 70 6c 65 0d 0d 66 |ted...Ex|ample..f|
|00003460| 72 61 6d 65 20 3d 20 28 | 31 30 2c 20 31 30 2c 20 |rame = (|10, 10, |
|00003470| 31 30 30 2c 20 31 30 30 | 20 29 0d 62 6f 78 5f 63 |100, 100| ).box_c|
|00003480| 6f 75 6e 74 20 3d 20 33 | 0d 62 6f 78 65 73 20 3d |ount = 3|.boxes =|
|00003490| 20 7b 20 28 35 30 2c 20 | 39 30 29 2c 20 28 34 30 | { (50, |90), (40|
|000034a0| 2c 20 34 30 29 2c 20 28 | 34 30 2c 20 35 30 29 20 |, 40), (|40, 50) |
|000034b0| 7d 0d 0d 72 65 74 75 72 | 6e 0d 0d 74 6f 70 6c 65 |}..retur|n..tople|
|000034c0| 66 74 73 20 3d 20 7b 20 | 28 31 30 2c 20 31 30 29 |fts = { |(10, 10)|
|000034d0| 2c 20 28 36 30 2c 20 31 | 30 29 2c 20 28 36 30 2c |, (60, 1|0), (60,|
|000034e0| 20 35 30 29 20 7d 0d 0d | 0d 0d 50 72 6f 62 6c 65 | 50) }..|..Proble|
|000034f0| 6d 20 30 39 20 2d 20 53 | 74 61 74 65 20 4d 61 63 |m 09 - S|tate Mac|
|00003500| 68 69 6e 65 0d 0d 74 79 | 70 65 20 47 65 74 4e 65 |hine..ty|pe GetNe|
|00003510| 78 74 43 68 61 72 50 72 | 6f 63 20 3d 20 66 75 6e |xtCharPr|oc = fun|
|00003520| 63 74 69 6f 6e 28 20 63 | 75 72 73 74 61 74 65 3a |ction( c|urstate:|
|00003530| 20 55 49 6e 74 33 32 20 | 29 3a 20 55 49 6e 74 33 | UInt32 |): UInt3|
|00003540| 32 3b 0d 0d 70 72 6f 63 | 65 64 75 72 65 20 53 74 |2;..proc|edure St|
|00003550| 61 74 65 4d 61 63 68 69 | 6e 65 49 6e 69 74 28 20 |ateMachi|neInit( |
|00003560| 76 61 72 20 73 74 61 74 | 65 5f 6d 61 63 68 69 6e |var stat|e_machin|
|00003570| 65 3a 20 48 61 6e 64 6c | 65 3b 20 73 74 61 74 65 |e: Handl|e; state|
|00003580| 73 3a 20 55 49 6e 74 33 | 32 3b 20 63 68 61 72 73 |s: UInt3|2; chars|
|00003590| 3a 0d 55 49 6e 74 33 32 | 20 29 3b 0d 70 72 6f 63 |:.UInt32| );.proc|
|000035a0| 65 64 75 72 65 20 41 64 | 64 54 72 61 6e 73 69 74 |edure Ad|dTransit|
|000035b0| 69 6f 6e 28 20 73 74 61 | 74 65 5f 6d 61 63 68 69 |ion( sta|te_machi|
|000035c0| 6e 65 3a 20 48 61 6e 64 | 6c 65 3b 20 73 74 61 74 |ne: Hand|le; stat|
|000035d0| 65 31 2c 20 73 74 61 74 | 65 32 3a 20 55 49 6e 74 |e1, stat|e2: UInt|
|000035e0| 33 32 3b 0d 66 69 72 73 | 74 5f 63 68 61 72 2c 20 |32;.firs|t_char, |
|000035f0| 6c 61 73 74 5f 63 68 61 | 72 3a 20 55 49 6e 74 33 |last_cha|r: UInt3|
|00003600| 32 20 29 3b 0d 70 72 6f | 63 65 64 75 72 65 20 52 |2 );.pro|cedure R|
|00003610| 75 6e 53 74 61 74 65 4d | 61 63 68 69 6e 65 28 20 |unStateM|achine( |
|00003620| 73 74 61 74 65 5f 6d 61 | 63 68 69 6e 65 3a 20 48 |state_ma|chine: H|
|00003630| 61 6e 64 6c 65 3b 20 73 | 74 61 72 74 5f 73 74 61 |andle; s|tart_sta|
|00003640| 74 65 3a 20 55 49 6e 74 | 33 32 3b 0d 47 65 74 4e |te: UInt|32;.GetN|
|00003650| 65 78 74 43 68 61 72 3a | 20 47 65 74 4e 65 78 74 |extChar:| GetNext|
|00003660| 43 68 61 72 50 72 6f 63 | 3b 20 76 61 72 20 73 74 |CharProc|; var st|
|00003670| 6f 70 5f 73 74 61 74 65 | 3a 20 55 49 6e 74 33 32 |op_state|: UInt32|
|00003680| 20 29 3b 0d 0d 54 68 69 | 73 20 70 72 6f 62 6c 65 | );..Thi|s proble|
|00003690| 6d 20 72 65 71 75 69 72 | 65 73 20 79 6f 75 20 74 |m requir|es you t|
|000036a0| 6f 20 6d 61 69 6e 74 61 | 69 6e 20 61 6e 64 20 6f |o mainta|in and o|
|000036b0| 70 65 72 61 74 65 20 61 | 20 73 74 61 74 65 20 6d |perate a| state m|
|000036c0| 61 63 68 69 6e 65 2c 20 | 63 6f 6e 73 69 73 74 69 |achine, |consisti|
|000036d0| 6e 67 0d 6f 66 20 72 75 | 6c 65 73 20 74 68 61 74 |ng.of ru|les that|
|000036e0| 20 63 68 61 6e 67 65 20 | 74 68 65 20 63 75 72 72 | change |the curr|
|000036f0| 65 6e 74 20 6d 61 63 68 | 69 6e 65 20 73 74 61 74 |ent mach|ine stat|
|00003700| 65 20 62 61 73 65 64 20 | 6f 6e 20 74 68 65 20 63 |e based |on the c|
|00003710| 75 72 72 65 6e 74 20 69 | 6e 70 75 74 2e 20 20 4f |urrent i|nput. O|
|00003720| 75 72 0d 73 74 61 74 65 | 20 6d 61 63 68 69 6e 65 |ur.state| machine|
|00003730| 73 20 64 6f 20 6e 6f 74 | 20 72 65 71 75 69 72 65 |s do not| require|
|00003740| 20 74 68 61 74 20 79 6f | 75 20 70 72 6f 64 75 63 | that yo|u produc|
|00003750| 65 20 61 6e 79 20 6f 75 | 74 70 75 74 20 6f 74 68 |e any ou|tput oth|
|00003760| 65 72 20 74 68 61 6e 20 | 74 68 65 0d 6d 61 63 68 |er than |the.mach|
|00003770| 69 6e 65 20 73 74 61 74 | 65 2e 0d 0d 53 74 61 74 |ine stat|e...Stat|
|00003780| 65 4d 61 63 68 69 6e 65 | 49 6e 69 74 20 63 72 65 |eMachine|Init cre|
|00003790| 61 74 65 73 20 61 20 6e | 65 77 2c 20 65 6d 70 74 |ates a n|ew, empt|
|000037a0| 79 20 73 74 61 74 65 20 | 6d 61 63 68 69 6e 65 20 |y state |machine |
|000037b0| 72 65 61 64 79 20 74 6f | 20 61 63 63 65 70 74 20 |ready to| accept |
|000037c0| 73 74 61 74 65 0d 74 72 | 61 6e 73 69 74 69 6f 6e |state.tr|ansition|
|000037d0| 73 2c 20 61 6e 64 20 63 | 6f 6e 74 61 69 6e 69 6e |s, and c|ontainin|
|000037e0| 67 20 73 74 61 74 65 73 | 20 73 74 61 74 65 73 20 |g states| states |
|000037f0| 28 6e 75 6d 62 65 72 73 | 20 31 20 74 6f 20 73 74 |(numbers| 1 to st|
|00003800| 61 74 65 73 29 20 61 6e | 64 20 63 68 61 72 73 0d |ates) an|d chars.|
|00003810| 63 68 61 72 61 63 74 65 | 72 73 20 28 6e 75 6d 62 |characte|rs (numb|
|00003820| 65 72 65 64 20 31 20 74 | 6f 20 63 68 61 72 73 29 |ered 1 t|o chars)|
|00003830| 2e 20 20 41 6c 6c 20 74 | 68 65 20 73 74 61 74 65 |. All t|he state|
|00003840| 20 6d 61 63 68 69 6e 65 | 20 69 6e 66 6f 72 6d 61 | machine| informa|
|00003850| 74 69 6f 6e 20 6d 75 73 | 74 20 62 65 0d 73 74 6f |tion mus|t be.sto|
|00003860| 72 65 64 20 69 6e 20 74 | 68 65 20 72 65 61 6c 20 |red in t|he real |
|00003870| 4d 61 63 20 6d 65 6d 6f | 72 79 20 6d 61 6e 61 67 |Mac memo|ry manag|
|00003880| 65 72 20 68 61 6e 64 6c | 65 20 2d 20 69 74 20 77 |er handl|e - it w|
|00003890| 69 6c 6c 20 62 65 20 64 | 69 73 70 6f 73 65 64 20 |ill be d|isposed |
|000038a0| 77 69 74 68 0d 44 69 73 | 70 6f 73 65 48 61 6e 64 |with.Dis|poseHand|
|000038b0| 6c 65 20 61 6e 64 20 74 | 68 61 74 20 6d 75 73 74 |le and t|hat must|
|000038c0| 20 72 65 6c 65 61 73 65 | 20 61 6c 6c 20 6d 65 6d | release| all mem|
|000038d0| 6f 72 79 2c 20 73 6f 20 | 64 6f 6e 74 20 73 74 6f |ory, so |dont sto|
|000038e0| 72 65 20 61 6e 79 20 65 | 78 74 72 61 0d 69 6e 66 |re any e|xtra.inf|
|000038f0| 6f 72 6d 61 74 69 6f 6e | 20 6f 75 74 73 69 64 65 |ormation| outside|
|00003900| 20 74 68 65 20 68 61 6e | 64 6c 65 2e 20 20 41 6c | the han|dle. Al|
|00003910| 73 6f 2c 20 79 6f 75 20 | 6d 75 73 74 20 62 65 20 |so, you |must be |
|00003920| 61 62 6c 65 20 74 6f 20 | 64 65 61 6c 20 77 69 74 |able to |deal wit|
|00003930| 68 20 68 61 76 69 6e 67 | 0d 6d 75 6c 74 69 70 6c |h having|.multipl|
|00003940| 65 20 73 74 61 74 65 20 | 6d 61 63 68 69 6e 65 20 |e state |machine |
|00003950| 69 6e 73 74 61 6e 74 69 | 61 74 65 64 20 73 69 6d |instanti|ated sim|
|00003960| 75 6c 74 61 6e 65 6f 75 | 73 6c 79 2e 0d 0d 41 64 |ultaneou|sly...Ad|
|00003970| 64 54 72 61 6e 73 69 74 | 69 6f 6e 20 61 64 64 73 |dTransit|ion adds|
|00003980| 20 61 20 74 72 61 6e 73 | 69 74 69 6f 6e 20 66 72 | a trans|ition fr|
|00003990| 6f 6d 20 73 74 61 74 65 | 31 20 74 6f 20 73 74 61 |om state|1 to sta|
|000039a0| 74 65 32 20 66 6f 72 20 | 63 68 61 72 61 63 74 65 |te2 for |characte|
|000039b0| 72 73 20 62 65 74 77 65 | 65 6e 0d 28 69 6e 63 6c |rs betwe|en.(incl|
|000039c0| 75 73 69 76 65 29 20 66 | 69 72 73 74 5f 63 68 61 |usive) f|irst_cha|
|000039d0| 72 20 61 6e 64 20 6c 61 | 73 74 5f 63 68 61 72 2e |r and la|st_char.|
|000039e0| 20 20 57 68 65 6e 20 79 | 6f 75 20 67 65 74 20 74 | When y|ou get t|
|000039f0| 6f 20 73 74 61 74 65 31 | 20 61 6e 64 20 67 65 74 |o state1| and get|
|00003a00| 20 61 0d 63 68 61 72 61 | 63 74 65 72 20 62 65 74 | a.chara|cter bet|
|00003a10| 77 65 65 6e 20 66 69 72 | 73 74 5f 63 68 61 72 20 |ween fir|st_char |
|00003a20| 61 6e 64 20 6c 61 73 74 | 5f 63 68 61 72 20 79 6f |and last|_char yo|
|00003a30| 75 20 73 68 6f 75 6c 64 | 20 70 72 6f 63 65 65 64 |u should| proceed|
|00003a40| 20 74 6f 20 73 74 61 74 | 65 32 2e 20 20 54 68 65 | to stat|e2. The|
|00003a50| 0d 6e 65 77 20 74 72 61 | 6e 73 69 74 69 6f 6e 20 |.new tra|nsition |
|00003a60| 6f 76 65 72 72 69 64 65 | 73 20 61 6e 64 20 70 72 |override|s and pr|
|00003a70| 65 76 69 6f 75 73 20 74 | 72 61 6e 73 69 74 69 6f |evious t|ransitio|
|00003a80| 6e 73 20 66 6f 72 20 74 | 68 65 73 65 20 63 68 61 |ns for t|hese cha|
|00003a90| 72 61 63 74 65 72 73 20 | 66 72 6f 6d 0d 73 74 61 |racters |from.sta|
|00003aa0| 74 65 31 20 28 69 65 2c | 20 69 66 20 79 6f 75 20 |te1 (ie,| if you |
|00003ab0| 67 65 74 20 74 72 61 6e | 73 69 74 69 6f 6e 20 31 |get tran|sition 1|
|00003ac0| 2d 3e 32 20 66 6f 72 20 | 63 68 61 72 73 20 31 2d |->2 for |chars 1-|
|00003ad0| 31 30 2c 20 61 6e 64 20 | 74 68 65 6e 20 31 2d 3e |10, and |then 1->|
|00003ae0| 33 20 66 6f 72 20 63 68 | 61 72 73 0d 35 2d 36 2c |3 for ch|ars.5-6,|
|00003af0| 20 79 6f 75 20 6e 6f 77 | 20 68 61 76 65 20 74 72 | you now| have tr|
|00003b00| 61 6e 73 69 74 69 6f 6e | 20 31 2d 3e 32 20 66 6f |ansition| 1->2 fo|
|00003b10| 72 20 63 68 61 72 73 20 | 31 2d 34 20 61 6e 64 20 |r chars |1-4 and |
|00003b20| 37 2d 31 30 20 61 6e 64 | 20 74 72 61 6e 73 69 74 |7-10 and| transit|
|00003b30| 69 6f 6e 20 31 2d 3e 33 | 0d 66 6f 72 20 63 68 61 |ion 1->3|.for cha|
|00003b40| 72 73 20 35 2d 36 29 2e | 0d 0d 52 75 6e 53 74 61 |rs 5-6).|..RunSta|
|00003b50| 74 65 4d 61 63 68 69 6e | 65 20 73 74 61 72 74 73 |teMachin|e starts|
|00003b60| 20 69 6e 20 73 74 61 72 | 74 5f 73 74 61 74 65 20 | in star|t_state |
|00003b70| 61 6e 64 20 63 61 6c 6c | 73 20 47 65 74 4e 65 78 |and call|s GetNex|
|00003b80| 74 43 68 61 72 20 72 65 | 70 65 61 74 65 64 6c 79 |tChar re|peatedly|
|00003b90| 20 75 6e 74 69 6c 0d 65 | 69 74 68 65 72 20 69 74 | until.e|ither it|
|00003ba0| 20 72 65 74 75 72 6e 73 | 20 30 20 6f 72 20 75 6e | returns| 0 or un|
|00003bb0| 74 69 6c 20 69 74 20 72 | 65 74 75 72 6e 73 20 61 |til it r|eturns a|
|00003bc0| 20 63 68 61 72 61 63 74 | 65 72 20 66 6f 72 20 77 | charact|er for w|
|00003bd0| 68 69 63 68 20 74 68 65 | 72 65 20 69 73 20 6e 6f |hich the|re is no|
|00003be0| 0d 74 72 61 6e 73 69 74 | 69 6f 6e 20 61 74 20 74 |.transit|ion at t|
|00003bf0| 68 65 20 63 75 72 72 65 | 6e 74 20 73 74 61 74 65 |he curre|nt state|
|00003c00| 2e 20 20 45 61 63 68 20 | 74 69 6d 65 20 47 65 72 |. Each |time Ger|
|00003c10| 4e 65 77 43 68 61 72 20 | 73 75 70 70 6c 69 65 73 |NewChar |supplies|
|00003c20| 20 61 20 63 68 61 72 61 | 63 74 65 72 2c 0d 74 68 | a chara|cter,.th|
|00003c30| 65 20 63 75 72 72 65 6e | 74 20 73 74 61 74 65 20 |e curren|t state |
|00003c40| 69 73 20 75 70 64 61 74 | 65 64 20 62 61 73 65 64 |is updat|ed based|
|00003c50| 20 6f 6e 20 74 68 65 20 | 74 72 61 6e 73 69 74 69 | on the |transiti|
|00003c60| 6f 6e 20 72 75 6c 65 20 | 74 68 61 74 20 61 70 70 |on rule |that app|
|00003c70| 6c 69 65 73 20 74 6f 20 | 74 68 61 74 0d 63 6f 6d |lies to |that.com|
|00003c80| 62 69 6e 61 74 69 6f 6e | 20 6f 66 20 63 75 72 72 |bination| of curr|
|00003c90| 65 6e 74 20 73 74 61 74 | 65 20 61 6e 64 20 63 75 |ent stat|e and cu|
|00003ca0| 72 72 65 6e 74 20 69 6e | 70 75 74 2e 20 20 57 68 |rrent in|put. Wh|
|00003cb0| 65 6e 20 47 65 74 4e 65 | 78 74 43 68 61 72 20 73 |en GetNe|xtChar s|
|00003cc0| 75 70 70 6c 69 65 73 20 | 61 0d 73 74 61 74 65 20 |upplies |a.state |
|00003cd0| 66 6f 72 20 77 68 69 63 | 68 20 6e 6f 20 74 72 61 |for whic|h no tra|
|00003ce0| 6e 73 69 74 69 6f 6e 20 | 72 75 6c 65 20 65 78 69 |nsition |rule exi|
|00003cf0| 73 74 73 2c 20 74 68 65 | 20 73 74 61 74 65 20 6d |sts, the| state m|
|00003d00| 61 63 68 69 6e 65 20 68 | 61 6c 74 73 20 61 6e 64 |achine h|alts and|
|00003d10| 20 74 68 65 0d 66 69 6e | 61 6c 20 73 74 61 74 65 | the.fin|al state|
|00003d20| 20 69 73 20 72 65 74 75 | 72 6e 65 64 20 69 6e 20 | is retu|rned in |
|00003d30| 73 74 6f 70 5f 73 74 61 | 74 65 2e 0d 0d 50 72 6f |stop_sta|te...Pro|
|00003d40| 62 6c 65 6d 20 31 30 20 | 2d 20 49 6e 74 65 72 70 |blem 10 |- Interp|
|00003d50| 72 65 74 65 72 0d 0d 57 | 72 69 74 65 20 61 6e 20 |reter..W|rite an |
|00003d60| 69 6e 74 65 72 70 72 65 | 74 65 72 20 66 6f 72 20 |interpre|ter for |
|00003d70| 74 68 69 73 20 73 69 6d | 70 6c 65 20 33 32 2d 62 |this sim|ple 32-b|
|00003d80| 69 74 20 69 6e 74 65 67 | 65 72 20 6c 61 6e 67 75 |it integ|er langu|
|00003d90| 61 67 65 20 77 69 74 68 | 20 32 36 20 72 65 67 69 |age with| 26 regi|
|00003da0| 73 74 65 72 73 0d 6c 61 | 62 65 6c 65 64 20 41 2d |sters.la|beled A-|
|00003db0| 5a 2e 0d 0d 74 79 70 65 | 20 52 65 67 69 73 74 65 |Z...type| Registe|
|00003dc0| 72 41 72 72 61 79 20 3d | 20 61 72 72 61 79 5b 30 |rArray =| array[0|
|00003dd0| 2e 2e 32 35 5d 20 6f 66 | 20 53 49 6e 74 33 32 3b |..25] of| SInt32;|
|00003de0| 0d 0d 70 72 6f 63 65 64 | 75 72 65 20 49 6e 74 65 |..proced|ure Inte|
|00003df0| 72 70 72 65 74 28 20 73 | 6f 75 72 63 65 3a 20 48 |rpret( s|ource: H|
|00003e00| 61 6e 64 6c 65 3b 20 76 | 61 72 20 72 65 73 75 6c |andle; v|ar resul|
|00003e10| 74 3a 20 52 65 67 69 73 | 74 65 72 41 72 72 61 79 |t: Regis|terArray|
|00003e20| 20 29 3b 0d 0d 73 6f 75 | 72 63 65 20 63 6f 6e 73 | );..sou|rce cons|
|00003e30| 69 73 74 73 20 6f 66 20 | 61 20 6e 75 6d 62 65 72 |ists of |a number|
|00003e40| 20 6f 66 20 6c 69 6e 65 | 73 20 6f 66 20 74 68 65 | of line|s of the|
|00003e50| 20 66 6f 72 6d 3a 0d 0d | 5b 3c 6c 61 62 65 6c 3e | form:..|[<label>|
|00003e60| 3a 5d 5b 3c 74 61 62 3e | 3c 69 6e 73 74 72 75 63 |:][<tab>|<instruc|
|00003e70| 74 69 6f 6e 3e 3c 74 61 | 62 3e 3c 6f 70 65 72 61 |tion><ta|b><opera|
|00003e80| 6e 64 2d 6c 69 73 74 3e | 5d 3c 63 72 3e 0d 0d 3c |nd-list>|]<cr>..<|
|00003e90| 6c 61 62 65 6c 3e 20 69 | 73 20 61 20 73 65 71 75 |label> i|s a sequ|
|00003ea0| 65 6e 63 65 20 6f 66 20 | 61 74 20 6c 65 61 73 74 |ence of |at least|
|00003eb0| 20 74 77 6f 20 61 6c 70 | 68 61 6e 75 6d 65 72 69 | two alp|hanumeri|
|00003ec0| 63 73 20 28 30 2d 39 61 | 2d 7a 41 2d 5a 5f 29 0d |cs (0-9a|-zA-Z_).|
|00003ed0| 28 63 61 73 65 73 65 6e | 73 69 74 69 76 65 29 2e |(casesen|sitive).|
|00003ee0| 0d 3c 6f 70 65 72 61 6e | 64 2d 6c 69 73 74 3e 20 |.<operan|d-list> |
|00003ef0| 69 73 20 61 20 73 65 71 | 75 65 6e 63 65 20 6f 66 |is a seq|uence of|
|00003f00| 20 6f 70 65 72 61 74 6f | 72 73 20 73 65 70 65 72 | operato|rs seper|
|00003f10| 61 74 65 64 20 62 79 20 | 63 6f 6d 6d 61 73 0d 6f |ated by |commas.o|
|00003f20| 74 68 65 72 20 74 68 61 | 6e 20 74 68 65 20 74 61 |ther tha|n the ta|
|00003f30| 62 73 20 61 6e 64 20 63 | 72 73 2c 20 6e 6f 20 77 |bs and c|rs, no w|
|00003f40| 68 69 74 65 20 73 70 61 | 63 65 20 69 73 20 61 6c |hite spa|ce is al|
|00003f50| 6c 6f 77 65 64 2e 0d 0d | 3c 69 6e 73 74 72 75 63 |lowed...|<instruc|
|00003f60| 74 69 6f 6e 3e 20 28 61 | 6e 64 20 61 70 70 72 6f |tion> (a|nd appro|
|00003f70| 70 72 69 61 74 65 20 6f | 70 65 72 61 6e 64 73 20 |priate o|perands |
|00003f80| 61 72 65 3a 0d 0d 4d 4f | 56 45 20 20 20 20 3c 76 |are:..MO|VE <v|
|00003f90| 61 6c 75 65 3e 2c 3c 72 | 65 67 69 73 74 65 72 3e |alue>,<r|egister>|
|00003fa0| 20 20 20 20 20 20 20 20 | 20 20 20 20 28 73 65 74 | | (set|
|00003fb0| 20 3c 72 65 67 69 73 74 | 65 72 3e 20 74 6f 20 3c | <regist|er> to <|
|00003fc0| 76 61 6c 75 65 3e 29 0d | 41 44 44 20 20 20 20 20 |value>).|ADD |
|00003fd0| 3c 76 61 6c 75 65 31 3e | 2c 3c 76 61 6c 75 65 32 |<value1>|,<value2|
|00003fe0| 3e 2c 3c 72 65 67 69 73 | 74 65 72 3e 20 20 28 73 |>,<regis|ter> (s|
|00003ff0| 65 74 20 3c 72 65 67 69 | 73 74 65 72 3e 20 74 6f |et <regi|ster> to|
|00004000| 20 3c 76 61 6c 75 65 31 | 3e 2b 3c 76 61 6c 75 65 | <value1|>+<value|
|00004010| 32 3e 29 0d 53 55 42 20 | 20 20 20 20 3c 76 61 6c |2>).SUB | <val|
|00004020| 75 65 31 3e 2c 3c 76 61 | 6c 75 65 32 3e 2c 3c 72 |ue1>,<va|lue2>,<r|
|00004030| 65 67 69 73 74 65 72 3e | 20 20 28 73 65 74 20 3c |egister>| (set <|
|00004040| 72 65 67 69 73 74 65 72 | 3e 20 74 6f 20 3c 76 61 |register|> to <va|
|00004050| 6c 75 65 31 3e 2d 3c 76 | 61 6c 75 65 32 3e 29 0d |lue1>-<v|alue2>).|
|00004060| 4a 4d 50 20 20 20 20 20 | 3c 6c 61 62 65 6c 3e 20 |JMP |<label> |
|00004070| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004080| 20 20 20 20 20 20 28 6a | 75 6d 70 20 74 6f 20 6c | (j|ump to l|
|00004090| 69 6e 65 20 6c 61 62 65 | 6c 65 64 20 77 69 74 68 |ine labe|led with|
|000040a0| 20 3c 6c 61 62 65 6c 3e | 29 0d 4a 45 51 20 20 20 | <label>|).JEQ |
|000040b0| 20 20 3c 76 61 6c 75 65 | 31 3e 2c 3c 76 61 6c 75 | <value|1>,<valu|
|000040c0| 65 32 3e 2c 3c 6c 61 62 | 65 6c 3e 20 20 20 20 20 |e2>,<lab|el> |
|000040d0| 28 6a 75 6d 70 20 74 6f | 20 3c 6c 61 62 65 6c 3e |(jump to| <label>|
|000040e0| 20 69 66 20 3c 76 61 6c | 75 65 31 3e 20 3d 20 3c | if <val|ue1> = <|
|000040f0| 76 61 6c 75 65 32 3e 29 | 0d 4a 4c 45 20 20 20 20 |value2>)|.JLE |
|00004100| 20 3c 76 61 6c 75 65 31 | 3e 2c 3c 76 61 6c 75 65 | <value1|>,<value|
|00004110| 32 3e 2c 3c 6c 61 62 65 | 6c 3e 20 20 20 20 20 28 |2>,<labe|l> (|
|00004120| 6a 75 6d 70 20 74 6f 20 | 3c 6c 61 62 65 6c 3e 20 |jump to |<label> |
|00004130| 69 66 20 3c 76 61 6c 75 | 65 31 3e 20 3c 3d 20 3c |if <valu|e1> <= <|
|00004140| 76 61 6c 75 65 32 3e 29 | 0d 4a 53 52 20 20 20 20 |value2>)|.JSR |
|00004150| 20 3c 6c 61 62 65 6c 3e | 20 20 20 20 20 20 20 20 | <label>| |
|00004160| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 28 | | (|
|00004170| 6a 75 6d 70 20 74 6f 20 | 73 75 62 72 6f 75 74 69 |jump to |subrouti|
|00004180| 6e 65 20 61 74 20 3c 6c | 61 62 65 6c 3e 29 0d 52 |ne at <l|abel>).R|
|00004190| 54 53 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |TS | |
|000041a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000041b0| 20 20 20 20 20 28 72 65 | 74 75 72 6e 20 66 72 6f | (re|turn fro|
|000041c0| 6d 20 73 75 62 72 6f 75 | 74 69 6e 65 29 0d 50 55 |m subrou|tine).PU|
|000041d0| 53 48 20 20 20 20 3c 76 | 61 6c 75 65 3e 20 20 20 |SH <v|alue> |
|000041e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000041f0| 20 20 20 20 28 70 75 73 | 68 20 76 61 6c 75 65 20 | (pus|h value |
|00004200| 6f 6e 20 74 6f 20 73 74 | 61 63 6b 29 0d 50 4f 50 |on to st|ack).POP|
|00004210| 20 20 20 20 20 3c 72 65 | 67 69 73 74 65 72 3e 20 | <re|gister> |
|00004220| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004230| 20 20 20 28 70 6f 70 20 | 76 61 6c 75 65 20 66 72 | (pop |value fr|
|00004240| 6f 6d 20 73 74 61 63 6b | 29 0d 0d 3c 72 65 67 69 |om stack|)..<regi|
|00004250| 73 74 65 72 3e 20 69 73 | 20 61 20 73 69 6e 67 6c |ster> is| a singl|
|00004260| 65 20 75 70 70 65 72 63 | 61 73 65 20 6c 65 74 74 |e upperc|ase lett|
|00004270| 65 72 20 69 6e 20 74 68 | 65 20 72 61 6e 67 65 20 |er in th|e range |
|00004280| 41 2e 2e 5a 0d 3c 6e 75 | 6d 62 65 72 3e 20 69 73 |A..Z.<nu|mber> is|
|00004290| 20 61 6e 20 6f 70 74 69 | 6f 6e 61 6c 20 6d 69 6e | an opti|onal min|
|000042a0| 75 73 20 73 69 67 6e 20 | 66 6f 6c 6c 6f 77 65 64 |us sign |followed|
|000042b0| 20 62 79 20 64 65 63 69 | 6d 61 6c 20 64 69 67 69 | by deci|mal digi|
|000042c0| 74 73 0d 3c 76 61 6c 75 | 65 3e 20 69 73 20 61 20 |ts.<valu|e> is a |
|000042d0| 3c 72 65 67 69 73 74 65 | 72 3e 20 6f 72 20 61 20 |<registe|r> or a |
|000042e0| 3c 6e 75 6d 62 65 72 3e | 0d 0d 4e 6f 74 65 20 74 |<number>|..Note t|
|000042f0| 68 61 74 20 74 68 65 20 | 64 61 74 61 20 73 74 61 |hat the |data sta|
|00004300| 63 6b 20 61 6e 64 20 73 | 75 62 72 6f 75 74 69 6e |ck and s|ubroutin|
|00004310| 65 20 73 74 61 63 6b 20 | 61 72 65 20 69 6e 64 65 |e stack |are inde|
|00004320| 70 65 6e 64 65 6e 74 20 | 73 74 61 63 6b 73 2e 20 |pendent |stacks. |
|00004330| 20 41 20 52 54 53 20 69 | 73 0d 75 73 65 64 20 74 | A RTS i|s.used t|
|00004340| 6f 20 73 74 6f 70 20 74 | 68 65 20 70 72 6f 67 72 |o stop t|he progr|
|00004350| 61 6d 20 28 74 68 61 74 | 20 69 73 2c 20 63 6f 6e |am (that| is, con|
|00004360| 73 69 64 65 72 20 74 68 | 61 74 20 79 6f 75 20 68 |sider th|at you h|
|00004370| 61 76 65 20 4a 53 52 65 | 64 20 74 6f 20 74 68 65 |ave JSRe|d to the|
|00004380| 20 69 6e 69 74 69 61 6c | 0d 6c 69 6e 65 20 6f 66 | initial|.line of|
|00004390| 20 74 68 65 20 73 6f 75 | 72 63 65 20 68 61 6e 64 | the sou|rce hand|
|000043a0| 6c 65 29 2e 20 20 46 6f | 72 20 65 78 61 6d 70 6c |le). Fo|r exampl|
|000043b0| 65 3a 0d 0d 09 50 55 53 | 48 09 31 30 0d 09 4a 53 |e:...PUS|H.10..JS|
|000043c0| 52 09 73 65 74 41 0d 09 | 4a 53 45 20 73 65 74 42 |R.setA..|JSE setB|
|000043d0| 0d 09 52 54 53 0d 73 65 | 74 41 3a 0d 09 50 4f 50 |..RTS.se|tA:..POP|
|000043e0| 09 41 0d 09 52 54 53 0d | 73 65 74 42 3a 09 4d 4f |.A..RTS.|setB:.MO|
|000043f0| 56 45 09 41 2c 42 0d 09 | 52 54 53 0d 09 0d 49 6e |VE.A,B..|RTS...In|
|00004400| 74 65 72 70 72 65 74 20 | 74 61 6b 65 73 20 74 68 |terpret |takes th|
|00004410| 65 20 73 6f 75 72 63 65 | 20 68 61 6e 64 6c 65 20 |e source| handle |
|00004420| 61 6e 64 20 4a 53 52 73 | 20 74 6f 20 69 74 2c 20 |and JSRs| to it, |
|00004430| 70 72 65 73 65 74 74 69 | 6e 67 20 74 68 65 20 72 |presetti|ng the r|
|00004440| 65 67 69 73 74 65 72 73 | 0d 61 63 63 6f 72 64 69 |egisters|.accordi|
|00004450| 6e 67 20 74 6f 20 74 68 | 65 20 72 65 67 69 73 74 |ng to th|e regist|
|00004460| 65 72 20 61 72 72 61 79 | 2e 20 20 57 68 65 6e 20 |er array|. When |
|00004470| 74 68 65 20 63 6f 64 65 | 20 72 65 74 75 72 6e 73 |the code| returns|
|00004480| 2c 20 74 68 65 20 72 65 | 67 69 73 74 65 72 20 61 |, the re|gister a|
|00004490| 72 72 61 79 20 69 73 0d | 73 65 74 20 74 6f 20 74 |rray is.|set to t|
|000044a0| 68 65 20 66 69 6e 61 6c | 20 76 61 6c 75 65 20 6f |he final| value o|
|000044b0| 66 20 61 6c 6c 20 74 68 | 65 20 72 65 67 69 73 74 |f all th|e regist|
|000044c0| 65 72 73 2e 20 20 42 6f | 74 68 20 73 75 62 72 6f |ers. Bo|th subro|
|000044d0| 75 74 69 6e 65 20 61 6e | 64 20 64 61 74 61 20 73 |utine an|d data s|
|000044e0| 74 61 63 6b 73 0d 73 68 | 6f 75 6c 64 20 62 65 20 |tacks.sh|ould be |
|000044f0| 6c 61 72 67 65 20 28 61 | 74 20 6c 65 61 73 74 20 |large (a|t least |
|00004500| 31 30 30 30 20 65 6e 74 | 72 69 65 73 20 65 61 63 |1000 ent|ries eac|
|00004510| 68 29 2e 0d 0d 45 4e 44 | 45 4e 44 45 4e 44 0d 00 |h)...END|ENDEND..|
|00004520| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004530| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004540| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004550| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004560| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004570| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004580| 00 00 01 00 00 00 05 68 | 00 00 04 68 00 00 00 46 |.......h|...h...F|
|00004590| 55 52 43 45 53 00 03 72 | 4d 79 52 65 73 6f 75 72 |URCES..r|MyResour|
|000045a0| 63 65 73 00 01 92 4d 59 | 52 45 47 49 4f 4e 53 00 |ces...MY|REGIONS.|
|000045b0| 09 21 50 72 6f 62 6c 65 | 6d 73 20 4d 61 63 48 61 |.!Proble|ms MacHa|
|000045c0| 63 6b 20 43 6f 6e 74 65 | 73 74 31 2e 73 69 74 69 |ck Conte|st1.siti|
|000045d0| 02 79 50 61 72 74 53 49 | 54 21 00 00 00 00 00 00 |.yPartSI|T!......|
|000045e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000045f0| 00 00 b1 b0 40 8b 00 00 | 00 00 00 00 05 ae 54 41 |....@...|......TA|
|00004600| 00 02 87 48 41 4e 44 4c | 45 00 00 58 41 42 4f 55 |...HANDL|E..XABOU|
|00004610| 54 5f 44 41 54 41 5f 43 | 4f 55 4e 54 00 00 7e 47 |T_DATA_C|OUNT..~G|
|00004620| 44 52 41 57 44 49 53 50 | 4c 41 59 49 54 45 4d 00 |DRAWDISP|LAYITEM.|
|00004630| 02 9b 4e 45 58 54 41 42 | 4f 55 54 44 41 54 41 45 |..NEXTAB|OUTDATAE|
|00004640| 4e 54 52 59 00 01 50 50 | 00 01 cc 47 45 54 48 41 |NTRY..PP|...GETHA|
|00004650| 4e 44 4c 45 53 49 5a 45 | 00 03 1d 50 54 52 00 00 |NDLESIZE|...PTR..|
|00004660| c8 5a 61 6e 79 3a 50 65 | 74 65 72 3a 50 61 73 63 |.Zany:Pe|ter:Pasc|
|00004670| 61 6c 3a 50 4e 4c 20 4c | 69 62 72 61 72 69 65 73 |al:PNL L|ibraries|
|00004680| 00 00 00 48 00 09 4d 6f | 6e 61 63 6f 00 a0 40 0c |...H..Mo|naco..@.|
|00004690| 6a 7a 00 51 a5 4a 00 00 | 01 d9 e8 00 01 cb 9b b0 |jz.Q.J..|........|
|000046a0| 01 d9 01 d9 00 00 00 06 | 00 04 00 2c 00 08 01 e5 |........|...,....|
|000046b0| 02 80 00 2c 00 08 01 e5 | 02 80 b1 ae ad 67 00 00 |...,....|.....g..|
|000046c0| 44 9f 00 00 44 9f 00 00 | 01 9a 01 00 00 00 04 18 |D...D...|........|
|000046d0| 52 2a 63 68 00 81 00 03 | 00 00 00 48 00 48 00 00 |R*ch....|...H.H..|
|000046e0| 00 00 02 da 02 28 ff e1 | ff e2 02 f9 02 46 03 47 |.....(..|.....F.G|
|000046f0| 05 28 03 fc 00 02 00 00 | 00 48 00 48 00 00 00 00 |.(......|.H.H....|
|00004700| 02 da 02 28 00 01 00 00 | 00 64 00 00 00 01 00 03 |...(....|.d......|
|00004710| 03 03 00 00 00 01 27 0f | 00 01 00 01 00 00 00 00 |......'.|........|
|00004720| 00 00 00 00 00 00 00 00 | 60 08 00 19 01 90 00 00 |........|`.......|
|00004730| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004740| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 01 |........|........|
|00004750| 06 4d 6f 6e 61 63 6f 00 | 00 00 00 00 00 00 00 00 |.Monaco.|........|
|00004760| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004770| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004780| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004790| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000047a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000047b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000047c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000047d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000047e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000047f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004800| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004810| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004820| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004830| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004840| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004850| 00 09 00 00 00 04 09 48 | 65 6c 76 65 74 69 63 61 |.......H|elvetica|
|00004860| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004870| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004880| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004890| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000048a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000048b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000048c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000048d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000048e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000048f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004900| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004910| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004920| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004930| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004940| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004950| 00 00 00 00 00 00 0c 43 | 6f 6e 66 69 64 65 6e 74 |.......C|onfident|
|00004960| 69 61 6c 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |ial.....|........|
|00004970| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004980| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004990| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000049a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000049b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000049c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000049d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000049e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000049f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004a00| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004a10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004a20| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004a30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004a40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004a50| 00 00 00 00 00 00 00 00 | 00 00 00 01 00 00 01 01 |........|........|
|00004a60| 00 00 80 00 00 00 80 00 | 00 00 80 00 00 00 80 00 |........|........|
|00004a70| 00 00 00 00 00 01 01 00 | 01 00 00 01 00 00 00 01 |........|........|
|00004a80| 00 48 01 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.H......|........|
|00004a90| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004aa0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004ab0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004ac0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004ad0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004ae0| 00 00 00 00 00 00 00 00 | 00 00 01 00 00 00 05 68 |........|.......h|
|00004af0| 00 00 04 68 00 00 00 46 | 01 cb 9e 28 25 d4 00 00 |...h...F|...(%...|
|00004b00| 00 1c 00 46 00 01 4d 50 | 53 52 00 00 00 12 42 42 |...F..MP|SR....BB|
|00004b10| 53 54 00 00 00 1e 03 ed | ff ff 00 00 00 00 00 00 |ST......|........|
|00004b20| 00 00 00 80 ff ff 00 00 | 00 4c 01 cb 9a 2c 00 00 |........|.L...,..|
|00004b30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b70| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+